public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "adam at adamrosenfield dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114826] New: Bogus -Warray-bounds warning for 32-byte array with certain march flags Date: Tue, 23 Apr 2024 15:45:05 +0000 [thread overview] Message-ID: <bug-114826-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114826 Bug ID: 114826 Summary: Bogus -Warray-bounds warning for 32-byte array with certain march flags Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: adam at adamrosenfield dot com Target Milestone: --- Sample code: ================== snip ================== typedef long unsigned int size_t; extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int memcmp (const void *__s1, const void *__s2, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); int foo() { char dest[32] = {0}; char src[32] = {0}; memcpy(dest, src, 32); char expected[32] = {0}; return memcmp(expected, dest, 32); } ================== snip ================== Compile as: gcc -c test.c -Wall -march=haswell -O3 Output: test.c: In function ‘foo’: test.c:9:10: warning: array subscript ‘<unnamed-unsigned:256>[0]’ is partly outside array bounds of ‘char[2]’ [-Warray-bounds=] 9 | char src[32] = {0}; | ^~~ This warning is clearly bogus, as there is no array of size 256 or size 2 here, and there's no subscripting going on in this array declaration. This occurs in GCC 13.2.0 and 13.1.0, but does not occur in GCC 12.x and earlier. This only occurs if the array size is exactly 32; other array sizes I've tried do not trigger this. This occurs with various different -march flags, including haswell, broadwell, skylake, knl, knm, and many more of the *lake arches; it does not occur with ivybridge and earlier.
next reply other threads:[~2024-04-23 15:45 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-23 15:45 adam at adamrosenfield dot com [this message] 2024-04-23 15:48 ` [Bug tree-optimization/114826] " pinskia at gcc dot gnu.org 2024-04-23 15:58 ` rguenth at gcc dot gnu.org 2024-04-23 17:35 ` [Bug tree-optimization/114826] [13 Regression] " pinskia at gcc dot gnu.org 2024-04-23 17:36 ` pinskia at gcc dot gnu.org 2024-05-13 11:27 ` rguenth at gcc dot gnu.org 2024-05-21 9:20 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-114826-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).