| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
* lib/intprops.h: Improve comments about promotion etc.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_P):
Port to ICC 2021.1, which has a non-working __builtin_mul_overflow_p.
Add a clause for other compilers that claim to support
__builtin_mul_overflow_p, since we might as well find out about
slackers other than Clang and ICC.
(INT_MULTIPLY_WRAPV): ICC 2021 has GCC bug 91450, so treat it
like older GCCs even when it claims to be a newer one.
|
|
|
|
|
|
|
|
|
|
| |
Reported by Stefan Liebler <stli@linux.ibm.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00152.html>.
* lib/intprops.h (_GL_HAS_BUILTIN_ADD_OVERFLOW): Don't define for
GCC 5.x and 6.x.
* lib/glob.c (size_add_wrapv): Don't use __builtin_add_overflow for
GCC 5.x and 6.x.
|
|
|
|
|
|
|
| |
* doc/intprops.texi (Checking Integer Overflow): New section.
* lib/intprops.h: From a suggestion by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-12/msg00051.html
(SAFE_INT_ADD, SAFE_INT_SUBTRACT, SAFE_INT_MULTIPLY): New macros.
|
|
|
|
|
|
|
|
|
| |
Problem reported by Nelson H. F. Beebe for clang 9.0.1 in:
https://lists.gnu.org/r/grep-devel/2020-09/msg00028.html
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_P) [__clang__]:
Define to 0.
* lib/xalloc-oversized.h (xalloc_oversized) [__clang__]:
Do not use __builtin_mul_overflow_p.
|
|
|
|
| |
* lib/intprops.h (_GL_SIGNED_INT_MAXIMUM): Simplify.
|
|
|
|
|
|
|
|
|
|
| |
The bug occurs when using INT_MULTIPLY_WRAPV (a, b, c) where B
is a bit-field, on older GCC or non-GCC compilers where we do
things ourselves instead of using __builtin_mul_overflow.
Without this fix, INT_MULTIPLY_WRAPV would not compile, due
to applying sizeof to a bit-field.
* lib/intprops.h (_GL_INT_MULTIPLY_RANGE_OVERFLOW):
Promote B before giving it to TYPE_WIDTH, in case B is a bit-field.
|
|
|
|
| |
* lib/intprops.h (_GL__GENERIC_BOGUS): Define to 1 on clang.
|
|
|
|
| |
* config/srclist.txt: Mark intprops.h as needing sync with glibc.
|
| |
|
|
|
|
|
|
|
|
| |
* m4/stdint.m4 (gl_STDINT_H): Check for SIZE_MAX also on
"clang -std=gnu99".
* lib/intprops.h (_GL_HAVE___TYPEOF__): Define to 1 also on clang.
* tests/test-stdint.c (verify_same_types): Enable the check also on
clang.
|
|
|
|
| |
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_P): Fix typo in comment.
|
| |
|
|
|
|
|
|
| |
* lib/intprops.h (INT_MULTIPLY_WRAPV): If GCC 8.x where 4 <= x,
remove workaround for GCC bug 91450 as the bug should be fixed
there too.
|
| |
|
|
|
|
|
| |
* lib/intprops.h (INT_MULTIPLY_WRAPV): If GCC 9.3 or later, do not
work around GCC bug 91450 as the bug should be fixed there.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Work around macOS header that has ‘#define __has_builtin(x) 0’
when compiled by GCC. Apple really, really doesn’t want you to
use GCC, apparently. Rroblem reported by Akim Demaille in:
https://lists.gnu.org/r/bug-bison/2019-10/msg00071.html
The fix is to not trust __has_builtin when being compiled by
recent-enough GCC.
* lib/intprops.h (__has_builtin)
(_GL_HAS___builtin_add_overflow, _GL_TEMPDEF___has_builtin):
* lib/verify.h (__has_builtin, _GL_HAS___builtin_unreachable)
(_GL_HAS___builtin_trap, _GL_TEMPDEF___has_builtin):
Remove. All uses removed.
* lib/intprops.h (_GL_HAS_BUILTIN_ADD_OVERFLOW): Use __has_builtin
directly, if defined and if not newer GCC.
* lib/verify.h (_GL_HAS_BUILTIN_TRAP, _GL_HAS_BUILTIN_UNREACHABLE):
New macro, that use __has_builtin directly, if defined and if
not newer GCC.
(assume): Use them.
|
|
|
|
|
|
|
|
| |
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-08/msg00076.html
* lib/intprops.h (_GL_HAS___builtin_mul_overflow): Remove.
(_GL_HAS_BUILTIN_MUL_OVERFLOW):
Go back to working around the Clang bug on macOS.
|
|
|
|
|
|
|
|
|
|
| |
Assume that __builtin_mul_overflow works OK with Clang on macOS.
Mattias Engdegård says it’s safe to assume the relevant library
is always available there.
* lib/intprops.h (_GL_HAS___builtin_mul_overflow):
New temporary internal macro.
(_GL_HAS_BUILTIN_MUL_OVERFLOW):
No need to work around the Clang bug on macOS.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Improve code generated by INT_ADD_WRAPV and INT_SUBTRACT_WRAPV
with Clang. Problem reported privately by Mattias Engdegård.
Also, insulate intprops.h and verify.h better against each other’s
definitions of __has_builtin on non-Clang hosts.
* lib/intprops.h (__has_builtin): Define a temporary substitute
if __has_builtin is not already defined.
(_GL_HAS___builtin_add_overflow, _GL_TEMPDEF___has_builtin):
New temporary internal macros.
(_GL_HAS_BUILTIN_ADD_OVERFLOW, _GL_HAS_BUILTIN_MUL_OVERFLOW):
Now two separate macros, replacing the old
_GL_HAS_BUILTIN_OVERFLOW, since we no longer assume that
__builtin_mul_overflow is like the rest. All uses changed.
(INT_ADD_WRAPV, INT_SUBTRACT_WRAPV, INT_MULTIPLY_WRAPV):
Adjust to above changes.
(_GL_INT_OP_WRAPV): Remove ‘builtin’ arg, since it’s no
longer relevant. All uses changed.
* lib/verify.h (__has_builtin): Treat like intprops.h,
so that the two .h files do not collide with each other.
(_GL_HAS___builtin_unreachable, _GL_HAS___builtin_trap)
(_GL_TEMPDEF___has_builtin): New temporary internal macros.
|
|
|
|
|
|
| |
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW):
Mention Clang in comment, responding to a query from
Mattias Engdegård.
|
|
|
|
|
| |
* lib/intprops.h (_GL_INT_OP_WRAPV): Fix recently-introduced
typos that were in a section not compiled by GCC.
|
|
|
|
|
|
|
|
| |
* lib/intprops.h (_GL_INT_OP_WRAPV_SMALLISH): New macro, defined
when __builtin_add_overflow etc. and _Generic are not used.
(_GL_INT_OP_WRAPV): Use it to support destinations that
are unsigned char or unsigned short, even in compilers
that lack __typeof__ and are not C11-compatible.
|
|
|
|
|
|
|
|
| |
* lib/intprops.h (_GL_BUILTIN_MUL_OVERFLOW):
Pacify GCC’s complaints about ignoring __builtin_mul_overflow’s
possibly-incorrect result.
(_GL_INT_MULTIPLY_RANGE_OVERFLOW): Pacify GCC’s complaints
about (A) used as a boolean, when A is an expression like 3 * 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add support for unsigned, unsigned long, and unsigned long long
results to INT_ADD_WRAPV, INT_SUBTRACT_WRAPV, and
INT_MULTIPLY_WRAPV. Also, work around GCC bug 91450, and fix a
bug with unsigned inputs reported by Eli Zaretskii in:
https://lists.gnu.org/r/bug-gnulib/2019-08/msg00012.html
* config/srclist.txt: Break the glibc connection for intprops.h
temporarily, while more testing is done in Gnulib-using apps.
* lib/intprops.h (INT_ADD_WRAPV, INT_SUBTRACT_WRAPV)
(INT_MULTIPLY_WRAPV, _GL_INT_OP_WRAPV, _GL_INT_OP_WRAPV_LONGISH):
Support unsigned results no narrower than unsigned int. Report
overflow correctly if some arguments are unsigned.
(_GL_BUILTIN_MUL_OVERFLOW): New macro, to work around GCC bug 91450.
(_GL_INT_OP_CALC): Simplify now that the OVERFLOW argument does
the right thing with narrow args.
(_GL_INT_OP_CALC1): Remove. All callers removed.
(_GL_INT_ADD_RANGE_OVERFLOW, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
(_GL_INT_MULTIPLY_RANGE_OVERFLOW): New macros.
* tests/test-intprops.c: Check for bugs and test new behavior.
|
| |
|
|
|
|
|
| |
* lib/intprops.h (_GL_BINARY_OP_OVERFLOW):
Use _GL_INT_CONVERT rather than reinventing it.
|
|
|
|
|
|
|
|
|
| |
This makes EXPR_SIGNED (e) easier to use, as it no longer
evaluates the expression E. Formerly, E was required to be free
of side effects.
* lib/intprops.h (_GL_INT_CONVERT, _GL_INT_NEGATE_CONVERT)
(EXPR_SIGNED, TYPE_WIDTH, _GL_INT_MINIMUM, _GL_INT_MAXIMUM)
(_GL_SIGNED_INT_MAXIMUM): Do not evaluate the expression arg.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Each /archive/html/ part can be replace with /r/.
Run this to induce the change:
git grep -l archive/html|xargs perl -pi -e 's,/archive/html/,/r/,g'
* ChangeLog: Perform that substitution.
* Makefile: Likewise.
* STATUS-libposix: Likewise.
* build-aux/bootstrap: Likewise.
* doc/maintain.texi: Likewise.
* gnulib-tool: Likewise.
* lib/allocator.h: Likewise.
* lib/argp-ba.c: Likewise.
* lib/argp-pv.c: Likewise.
* lib/canon-host.c: Likewise.
* lib/canonicalize-lgpl.c: Likewise.
* lib/float.in.h: Likewise.
* lib/fstat.c: Likewise.
* lib/getdelim.c: Likewise.
* lib/getprogname.c: Likewise.
* lib/glthread/thread.h: Likewise.
* lib/intprops.h: Likewise.
* lib/mbsrtowcs-state.c: Likewise.
* lib/safe-read.c: Likewise.
* lib/signal.in.h: Likewise.
* lib/stat.c: Likewise.
* lib/stdbool.in.h: Likewise.
* lib/stdio-impl.h: Likewise.
* lib/stdio.in.h: Likewise.
* lib/sysexits.in.h: Likewise.
* lib/timespec.h: Likewise.
* lib/wcsrtombs-state.c: Likewise.
* m4/alloca.m4: Likewise.
* m4/extern-inline.m4: Likewise.
* m4/fstatat.m4: Likewise.
* m4/gnulib-common.m4: Likewise.
* m4/lib-ignore.m4: Likewise.
* m4/printf.m4: Likewise.
* m4/regex.m4: Likewise.
* m4/stat-size.m4: Likewise.
* m4/std-gnu11.m4: Likewise.
* m4/stdbool.m4: Likewise.
* m4/sys_types_h.m4: Likewise.
* m4/threadlib.m4: Likewise.
* m4/vararrays.m4: Likewise.
* pygnulib/GLImport.py: Likewise.
* tests/test-exp.h: Likewise.
* tests/test-exp2.h: Likewise.
* tests/test-expm1.h: Likewise.
* tests/test-fflush2.c: Likewise.
* tests/test-getopt_long.h: Likewise.
* tests/test-intprops.c: Likewise.
* tests/test-log.h: Likewise.
* tests/test-log10.h: Likewise.
* tests/test-log1p.h: Likewise.
* tests/test-log2.h: Likewise.
* tests/test-printf-posix.h: Likewise.
* tests/test-regex.c: Likewise.
* tests/test-snprintf-posix.h: Likewise.
* tests/test-sprintf-posix.h: Likewise.
* tests/test-stdalign.c: Likewise.
* tests/test-stdbool.c: Likewise.
* tests/test-vasnprintf-posix.c: Likewise.
* tests/test-vasprintf-posix.c: Likewise.
* top/maint.mk: Likewise.
|
|
|
|
|
| |
* users.txt: Remove mention of 'newts'.
* lib/localename.c: Update comment about LANG_SOTHO.
|
| |
|
|
|
|
|
|
|
| |
Port to icc (ICC) 17.0.4 20170411, which defines __GNUC__ to be 5
but does not support __builtin_add_overflow etc.
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW) [__ICC]:
Define to 0.
|
|
|
|
|
|
|
|
|
|
| |
Problem reported by Ævar Arnfjörð Bjarmason in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00054.html
* lib/intprops.h: Do not include verify.h, and move compile-time
checks from here ...
* tests/test-intprops.c (main): ... to here, if they’re not here
already. Check widths of other standard integer types.
* modules/intprops (Depends-on): Remove ‘verify’.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib/intprops.h: Improve and shorten commentary.
For the record, if we ever run into a pedantic compiler that
behaves differently from GCC when converting an out-of-range value
to a signed integer, we can work around the problem with something
like the following code, where UCT is the signed counterpart of T
(UCT is sometimes narrower than UT) and all callers are changed
accordingly:
((t) ((ut) (a) op (ut) (b)))
(TYPE_MINIMUM (t) <= (uct) ((ut) (a) op (ut) (b)) \
? ((t) (uct) (((ut) (a) op (ut) (b)) - TYPE_MINIMUM (t)) \
+ TYPE_MINIMUM (t)) \
: (t) (uct) ((ut) (a) op (ut) (b)))
|
| |
|
|
|
|
|
|
|
| |
* lib/intprops.h (_GL_INT_OP_CALC): Document that UT no longer
needs to be the same width as T; it can be wider.
Change callers so that UT is at least as wide as unsigned int,
as I suspect that this is less likely to run into compiler bugs.
|
|
|
|
|
|
|
|
| |
Problem reported by Gavin Smith in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
* lib/intprops.h (_GL_INT_OP_WRAPV_VIA_UNSIGNED):
Convert unsigned to signed via the usual rather than the standard way,
to avoid a compiler bug in Oracle Studio 12.3 x86.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Work around LLVM bug 16404, which is still not fixed.
https://llvm.org/bugs/show_bug.cgi?id=16404
Problem reported by Nelson H. F. Beebe.
* lib/glob.c, lib/intprops.h, lib/xalloc-oversized.h (__has_builtin):
Remove.
* lib/glob.c (size_add_wrapv):
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW, _GL_HAS_BUILTIN_OVERFLOW_P):
* lib/xalloc-oversized.h (xalloc_oversized):
Do not use overflow builtins if Clang.
|
|
|
|
|
|
|
|
|
|
| |
* build-aux/gendocs.sh (version):
* doc/gendocs_template:
* doc/gendocs_template_min:
* doc/gnulib.texi:
* lib/version-etc.c (COPYRIGHT_YEAR):
Update copyright dates by hand in templates and the like.
* all files: Run 'make update-copyright'.
|
|
|
|
|
|
|
|
|
| |
Problem reported by Alexander Samoilov in:
http://lists.gnu.org/archive/html/bug-gnulib/2016-10/msg00166.html
http://savannah.nongnu.org/bugs/?49448
* lib/intprops.h (_GL_HAVE___TYPEOF__) [__IBM__TYPEOF__]:
Define to 1 only for XL C 12.1 or later, since this bug
occurs in XL C for AIX 6.0 but not in 12.1.
|
|
|
|
|
|
|
|
| |
* lib/intprops.h (TYPE_WIDTH): New macro.
(TYPE_MAXIMUM, _GL_SIGNED_INT_MAXIMUM, INT_STRLEN_BOUND):
* lib/ftoastr.h (_GL_FLOAT_DIG_BITS_BOUND):
* lib/parse-datetime.y (parse_datetime2):
Use it.
|
|
|
|
|
|
|
|
|
|
| |
* lib/intprops.h (INT_NEGATE_OVERFLOW): Tune for platforms like
GCC 5 and 6 that have __builtin_sub_overflow but not
__builtin_sub_overflow_p. With the recent changes, these
platforms are a tiny bit faster with the INT_NEGATE_RANGE_OVERFLOW
implementation than with INT_SUBTRACT_OVERFLOW implementation,
since the former needs just one runtime comparison whereas the
latter needs two.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib/intprops.h (__has_builtin): Move earlier.
(_GL_HAS_BUILTIN_OVERFLOW): Rename from
_GL_HAS_BUILTIN_OVERFLOW_WITH_NULL and don't worry about whether
the last argument can be null. All uses changed.
(_GL_HAS_BUILTIN_OVERFLOW_P): Also test __has_builtin.
(_GL_ADD_OVERFLOW, _GL_SUBTRACT_OVERFLOW, _GL_MULTIPLY_OVERFLOW):
Don't try to use 3rd arg null, as this doesn't work on GCC 6.2.0
and it's not clear which GCC versions it works for.
(_GL_INT_OP_WRAPV): Use _GL_HAS_BUILTIN_OVERFLOW instead of
its definiens.
|
|
|
|
|
|
| |
* lib/intprops.h (_GL_ADD_OVERFLOW, _GL_SUBTRACT_OVERFLOW)
(_GL_MULTIPLY_OVERFLOW): Use __typeof__ as in the GCC manual.
This avoids computing the expression's value (which might overflow!).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In gcc 6, __builtin_add_overflow, __builtin_sub_overflow and
__builtin_mul_overflow each accept a NULL pointer as the third
argument. However in gcc 7, that is no longer accepted.
Instead, one must use the "_p"-suffixed names, with which, the
third parameter is no longer a pointer.
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_WITH_NULL): Correct
the definition: not true for gcc 7 and subsequent.
(_GL_HAS_BUILTIN_OVERFLOW_P): Define.
(_GL_ADD_OVERFLOW, _GL_SUBTRACT_OVERFLOW, _GL_MULTIPLY_OVERFLOW):
Provide new definitions for gcc 7 and subsequent.
* lib/xalloc-oversized.h (xalloc_oversized): Provide a definition
that works with gcc-7.
|
|
|
|
|
| |
* lib/intprops.h (_GL_ADD_OVERFLOW): Add backslash.
(_GL_SUBTRACT_OVERFLOW,_GL_MULTIPLY_OVERFLOW): Likewise.
|
|
|
|
|
|
|
|
|
| |
Problem reported by John E. Malmberg in: https://bugs.gnu.org/24300#13
* lib/intprops.h (_GL_INT_OP_WRAPV_LONGISH)
[__GNUC__ < 5 && !__has_builtin (__builtin_add_overflow)
&& (__STDC_VERSION__ < 201112 || _GL__GENERIC_BOGUS)
&& !defined LLONG_MAX]:
Remove stray paren.
|
|
|
|
|
|
|
| |
Problem reported by John E. Malmberg in: https://bugs.gnu.org/24300
* doc/posix-headers/limits.texi: Document the problem.
* lib/intprops.h (LLONG_MAX, LLONG_MIN) [__INT64_MAX]:
Define if not already defined.
|