[pypy-svn] r72536 - pypy/trunk/pypy/translator/c/src

arigo at codespeak.net arigo at codespeak.net
Mon Mar 22 12:38:24 CET 2010


Author: arigo
Date: Mon Mar 22 12:38:22 2010
New Revision: 72536

Modified:
   pypy/trunk/pypy/translator/c/src/int.h
Log:
Can a C compiler be too clever and think it can "prove" that
r >= x always holds here?  Yes.  Hence the casting.


Modified: pypy/trunk/pypy/translator/c/src/int.h
==============================================================================
--- pypy/trunk/pypy/translator/c/src/int.h	(original)
+++ pypy/trunk/pypy/translator/c/src/int.h	Mon Mar 22 12:38:22 2010
@@ -57,11 +57,11 @@
 	else FAIL_OVF("integer addition")
 
 #define OP_INT_ADD_NONNEG_OVF(x,y,r)  /* y can be assumed >= 0 */ \
-    OP_INT_ADD(x,y,r); \
+    r = (long)((unsigned long)x + (unsigned long)y); \
     if (r >= (x)); \
     else FAIL_OVF("integer addition")
-/* XXX can a C compiler be too clever and think it can "prove" that
- * r >= x always hold above? */
+/* Can a C compiler be too clever and think it can "prove" that
+ * r >= x always holds above?  Yes.  Hence the casting. */
 
 #define OP_INT_SUB(x,y,r)     r = (x) - (y)
 



More information about the Pypy-commit mailing list