diff options
author | Hans-Peter Nilsson <hp@axis.com> | 2024-09-29 05:47:03 +0200 |
---|---|---|
committer | Hans-Peter Nilsson <hp@bitrange.com> | 2024-10-01 02:14:10 +0200 |
commit | b1696ffd46872907b324996d4cdf28a2b9df209d (patch) | |
tree | 3b1a3c8d7136566d63101f83428670dcb7dfa5d3 /gcc/tree-ssa-loop.c | |
parent | ab07db3f24e203971c2190bdeec1732942f02bdd (diff) | |
download | gcc-b1696ffd46872907b324996d4cdf28a2b9df209d.zip gcc-b1696ffd46872907b324996d4cdf28a2b9df209d.tar.gz gcc-b1696ffd46872907b324996d4cdf28a2b9df209d.tar.bz2 |
libstdc++-v3: Fix signed-overflow warning for newlib/ctype_base.h, PR116895
There are 100+ regressions when running the g++ testsuite for newlib
targets (probably excepting ARM-based ones) e.g cris-elf after commit
r15-3859-g63a598deb0c9fc "libstdc++: #ifdef out #pragma GCC
system_header", which effectively no longer silences warnings for
gcc-installed system headers. Some of these regressions are fixed by
r15-3928. For the remaining ones, there's in g++.log:
FAIL: g++.old-deja/g++.robertl/eb79.C -std=c++26 (test for excess errors)
Excess errors:
/gccobj/cris-elf/libstdc++-v3/include/cris-elf/bits/ctype_base.h:50:53: \
warning: overflow in conversion from 'int' to 'std::ctype_base::mask' \
{aka 'char'} changes value from '151' to '-105' [-Woverflow]
This is because the _B macro in newlib's ctype.h (from where the
"_<letter>" macros come) is bit 7, the sign-bit of 8-bit types:
#define _B 0200
Using it in an int-expression that is then truncated to 8 bits will
"change" the value to negative for a default-signed char. If this
code was created from scratch, it should have been an unsigned type,
however it's not advisable to change the type of mask as this affects
the API. The least ugly option seems to be to silence the warning by
explict casts in the initializer, and for consistency, doing it for
all members.
PR libstdc++/116895
* config/os/newlib/ctype_base.h: Avoid signed-overflow warnings by
explicitly casting initializer expressions to mask.
Diffstat (limited to 'gcc/tree-ssa-loop.c')
0 files changed, 0 insertions, 0 deletions