public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107477] New: spurious -Wrestrict warning
@ 2022-10-31 18:21 stsp at users dot sourceforge.net
2022-10-31 18:27 ` [Bug tree-optimization/107477] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: stsp at users dot sourceforge.net @ 2022-10-31 18:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107477
Bug ID: 107477
Summary: spurious -Wrestrict warning
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: stsp at users dot sourceforge.net
Target Milestone: ---
Created attachment 53804
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53804&action=edit
test case
$ gcc -Wrestrict -O1 -c www.c
In file included from /usr/include/string.h:535,
from www.c:1:
In function ‘strcpy’,
inlined from ‘foo’ at www.c:11:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:79:10: warning:
‘__builtin_strcpy’ accessing 1 byte at offsets [0, 327680] and [0, 327680]
overlaps 1 byte at offset [0, 327679] [-Wrestrict]
Or:
$ gcc -Wrestrict -m32 -O2 -c www.c
In file included from /usr/include/string.h:535,
from www.c:1:
In function ‘strcpy’,
inlined from ‘foo’ at www.c:11:5:
/usr/include/bits/string_fortified.h:79:10: warning: ‘__builtin_strcpy’
accessing 1 byte at offsets [0, 327680] and [0, 327680] overlaps 1 byte at
offset [0, 327679] [-Wrestrict]
79 | return __builtin___strcpy_chk (__dest, __src, __glibc_objsize
(__dest)
It doesn't warn with -O2 without -m32.
And if we remove the lines 12,13 of a
test-case, then it never warns with -O2,
whether its -m32 or not.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/107477] spurious -Wrestrict warning
2022-10-31 18:21 [Bug c/107477] New: spurious -Wrestrict warning stsp at users dot sourceforge.net
@ 2022-10-31 18:27 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-31 18:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107477
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Adding:
if (s < 0) __builtin_unreachable();
"fixes" the warning.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-31 18:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31 18:21 [Bug c/107477] New: spurious -Wrestrict warning stsp at users dot sourceforge.net
2022-10-31 18:27 ` [Bug tree-optimization/107477] " pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).