https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123477
Bug ID: 123477
Summary: wrong bound check
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: rootkit85 at yahoo dot it
Target Milestone: ---
Created attachment 63276
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63276&action=edit
reproducer
the attached file produces a false positive warning with this command line:
$ gcc -ftrivial-auto-var-init=zero -O2
-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -o /dev/null -c size.c
In file included from /usr/include/features.h:540,
from /usr/include/unistd.h:25,
from size.c:2:
In function ‘read’,
inlined from ‘test_read’ at size.c:12:7:
/usr/include/bits/unistd.h:32:10: warning: ‘__read_alias’ specified size
between 18446744069414585345 and 18446744073709551615 exceeds maximum object
size 9223372036854775807 [-Wstringop-overflow=]
32 | return __glibc_fortify (read, __nbytes, sizeof (char),
| ^~~~~~~~~~~~~~~
size.c: In function ‘test_read’:
size.c:7:14: note: destination object allocated here
7 | char buffer[1024];
| ^~~~~~
/usr/include/bits/unistd-decl.h:29:16: note: in a call to function
‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’
29 | extern ssize_t __REDIRECT_FORTIFY (__read_alias, (int __fd, void
*__buf,
| ^~~~~~~~~~~~~~~~~~
Some information:
$ cat /etc/fedora-release
Fedora release 44 (Rawhide)
$ rpm -q gcc
gcc-16.0.0-0.4.fc44.aarch64
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/16/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,cobol,algol68,lto
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugzilla.redhat.com/ --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu
--enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-16.0.0-build/gcc-16.0.0-20260103/obj-aarch64-redhat-linux/isl-install
--enable-gnu-indirect-function --build=aarch64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
--disable-libssp --disable-libquadmath
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20260103 (Red Hat 16.0.0-0) (GCC)