src/SDCCval.c (valMult): fixex overflow detection of negativ int
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 9 Aug 2003 17:18:13 +0000 (17:18 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 9 Aug 2003 17:18:13 +0000 (17:18 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2821 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCval.c

index c175d63e6305bcb1594ab3f863d7d877bb0baddb..7f65ec78ea39fbdb3193b8f4a5f4299e42e4de2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-08-09  Bernhard Held <bernhard@bernhardheld.de>
+
+       * src/SDCCval.c (valMult): fixex overflow detection of negativ int
+
 2003-08-07  Erik Petrich <epetrich@ivorytower.norman.ok.us>
 
        * src/z80/ralloc.c (joinPushes): made compatible with new signedness
index 63fac609388aa2d1e7b39e827a1743831e9254a9..62ffcec2a1670ff07d3443ab3fc7a03778b6d5b8 100644 (file)
@@ -1039,10 +1039,11 @@ valMult (value * lval, value * rval)
       if (SPEC_LONG (val->type))
         SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) *
                                        (TYPE_UDWORD) floatFromVal (rval);
-      else
+      else /* int */
         {
           TYPE_UDWORD ul = (TYPE_UWORD) floatFromVal (lval) *
                            (TYPE_UWORD) floatFromVal (rval);
+
           SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) ul;
           if (!options.lessPedantic)
             {
@@ -1053,7 +1054,10 @@ valMult (value * lval, value * rval)
                 }
               else /* signed result */
                 {
-                  if ((TYPE_DWORD) ul != SPEC_CVAL (val->type).v_int)
+                  TYPE_DWORD l = (TYPE_WORD) floatFromVal (lval) *
+                                 (TYPE_WORD) floatFromVal (rval);
+
+                  if (l != SPEC_CVAL (val->type).v_int)
                     werror (W_INT_OVL);
                 }
             }