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.
  • [Bug c/107477] New: spuriou... stsp at users dot sourceforge.net via Gcc-bugs

Reply via email to