https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103292
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |DUPLICATE Component|c |middle-end Blocks| |56456 CC| |jeffreyalaw at gmail dot com --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- The originally intended purpose of this instance of -Warray-bounds was to warn for accesses to smaller buffers by larger lvalues, like in this function: struct A { int i; }; struct B { long j; }; struct B* make_B_from_A (const struct A *p) { struct B *q = __builtin_malloc (sizeof *p); // should be sizeof *q q->j = p->i; return q; } Here a warning should be issued regardless of whether -fstrict-aliasing is in effect because the access is out of bounds. That the warning also triggers in instances when the problem isn't one of an out-of-bounds access but rather an aliasing violation was incidental (i.e., I didn't set out with that as a goal), but because -Wstrict-aliasing in GCC is very limited, seemed like a bonus. So an argument could be (and in pr98503 in fact was) made that the instances of -Warray-bounds where the ultimate access is strictly in bounds should be replaced by one of -Wstrict-aliasing, which is enabled only when -fstrict-aliasing is in effect. I agreed and submitted a patch to do that: https://gcc.gnu.org/pipermail/gcc-patches/2021-January/564483.html Regrettably, the change was rejected. I CC the reviewer for his comments. *** This bug has been marked as a duplicate of bug 98503 *** Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds