[PPL-devel] [GIT] ppl/ppl(master): Avoid implicit conversions reducing size of underlying type.

Enea Zaffanella zaffanella at cs.unipr.it
Thu Nov 3 19:50:07 CET 2011


Module: ppl/ppl
Branch: master
Commit: 9954d6d0b6f5a88175c0f00eb0aae767d862dc4b
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9954d6d0b6f5a88175c0f00eb0aae767d862dc4b

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Thu Nov  3 19:33:35 2011 +0100

Avoid implicit conversions reducing size of underlying type.
Detected by ECLAIR service utypflag.

---

 src/checked_int.inlines.hh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/checked_int.inlines.hh b/src/checked_int.inlines.hh
index 10ab8da..c45f306 100644
--- a/src/checked_int.inlines.hh
+++ b/src/checked_int.inlines.hh
@@ -662,14 +662,14 @@ assign_unsigned_int_mpz(To& to, const mpz_class& from, Rounding_Dir dir) {
     return set_neg_overflow_int<To_Policy>(to, dir);
   if (sizeof(To) <= sizeof(unsigned long)) {
     if (!To_Policy::check_overflow) {
-      to = from.get_ui();
+      to = static_cast<To>(from.get_ui());
       return V_EQ;
     }
     if (from.fits_ulong_p()) {
       unsigned long v = from.get_ui();
       if (PPL_GT_SILENT(v, (Extended_Int<To_Policy, To>::max)))
 	return set_pos_overflow_int<To_Policy>(to, dir);
-      to = v;
+      to = static_cast<To>(v);
       return V_EQ;
     }
   }




More information about the PPL-devel mailing list