Mercurial > hg > octave-lojdl > gnulib-hg
changeset 14824:10982c2d5cdb
intprops: shorten, to pacify gcc -Woverlength-strings
* lib/intprops.h (_GL_INT_CONVERT, _GL_INT_NEGATE_CONVERT):
(_GL_BINARY_OP_OVERFLOW): Say "0 * (x)" rather than "(x) - (x)",
so that, for example, verify (INT_MULTIPLY_OVERFLOW (...)) is less
likely to run afoul of C compiler limits for string constant lengths.
See <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00528.html>.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 24 May 2011 16:45:14 -0700 |
parents | 3fe3b9fc9c12 |
children | 82b7de24fe12 |
files | ChangeLog lib/intprops.h |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-05-24 Paul Eggert <eggert@cs.ucla.edu> + + intprops: shorten, to pacify gcc -Woverlength-strings + * lib/intprops.h (_GL_INT_CONVERT, _GL_INT_NEGATE_CONVERT): + (_GL_BINARY_OP_OVERFLOW): Say "0 * (x)" rather than "(x) - (x)", + so that, for example, verify (INT_MULTIPLY_OVERFLOW (...)) is less + likely to run afoul of C compiler limits for string constant lengths. + See <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00528.html>. + 2011-05-24 Eric Blake <eblake@redhat.com> docs: document recently fixed glibc printf bug
--- a/lib/intprops.h +++ b/lib/intprops.h @@ -25,11 +25,11 @@ /* Return a integer value, converted to the same type as the integer expression E after integer type promotion. V is the unconverted value. E should not have side effects. */ -#define _GL_INT_CONVERT(e, v) ((e) - (e) + (v)) +#define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */ -#define _GL_INT_NEGATE_CONVERT(e, v) ((e) - (e) - (v)) +#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v)) /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ @@ -314,7 +314,7 @@ 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 ((b) - (b) + (a)), \ - _GL_INT_MAXIMUM ((b) - (b) + (a))) + _GL_INT_MINIMUM (0 * (b) + (a)), \ + _GL_INT_MAXIMUM (0 * (b) + (a))) #endif /* _GL_INTPROPS_H */