Mercurial > hg > octave-nkf > gnulib-hg
changeset 14779:70726a18c2ed
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
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00426.html>.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 20 May 2011 11:30:16 -0700 |
parents | 85c9ed97c132 |
children | 6d28ad2791ef |
files | ChangeLog lib/intprops.h |
diffstat | 2 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-05-20 Paul Eggert <eggert@cs.ucla.edu> + + 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 + <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00426.html>. + 2011-05-20 Eric Blake <eblake@redhat.com> perror: work around FreeBSD bug
--- a/lib/intprops.h +++ b/lib/intprops.h @@ -311,13 +311,10 @@ /* Return 1 if the expression A <op> 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 */