From: Paul Eggert Date: Fri, 20 May 2011 18:30:16 +0000 (-0700) Subject: intprops: remove assumption about A|B representation X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48552f312571692c5c0141c8d6a94f8efb65728a;p=pspp intprops: remove assumption about A|B representation * lib/intprops.h (_GL_BINARY_OP_OVERFLOW): Do not assume that A|B is a valid integer if both A and B are. Although this is true for all known practical hosts, the C standard doesn't guarantee it, and the code need not assume it. Also, this change may work around HP-UX 11.23 and IRIX 6.5 cc bugs reported by Bruno Haible in . --- diff --git a/ChangeLog b/ChangeLog index e1f9b6773d..1f7eef809b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-05-20 Paul Eggert + + intprops: remove assumption about A|B representation + * lib/intprops.h (_GL_BINARY_OP_OVERFLOW): Do not assume that A|B + is a valid integer if both A and B are. Although this is true for + all known practical hosts, the C standard doesn't guarantee it, + and the code need not assume it. Also, this change may work around + HP-UX 11.23 and IRIX 6.5 cc bugs reported by Bruno Haible in + . + 2011-05-20 Eric Blake perror: work around FreeBSD bug diff --git a/lib/intprops.h b/lib/intprops.h index bd9f04042e..293204ab43 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -311,13 +311,10 @@ /* Return 1 if the expression A B would overflow, where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, assuming MIN and MAX are the minimum and maximum for the result type. - - This macro assumes that A | B is a valid integer if both A and B are, - which is true of all known practical hosts. If this is a problem - for you, please let us know how to fix it for your host. */ + Arguments should be free of side effects. */ #define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ op_result_overflow (a, b, \ - _GL_INT_MINIMUM ((a) | (b)), \ - _GL_INT_MAXIMUM ((a) | (b))) + _GL_INT_MINIMUM ((b) - (b) + (a)), \ + _GL_INT_MAXIMUM ((b) - (b) + (a))) #endif /* _GL_INTPROPS_H */