From 48552f312571692c5c0141c8d6a94f8efb65728a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 20 May 2011 11:30:16 -0700 Subject: [PATCH] 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 . --- ChangeLog | 10 ++++++++++ lib/intprops.h | 9 +++------ 2 files changed, 13 insertions(+), 6 deletions(-) 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 */ -- 2.30.2