https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453
Bug ID: 102453 Summary: buffer overflow by atomic built-ins not diagnosed Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The buffer overflow by the straight assignment in f() below is diagnosed as expected but the equivalent overflow by the atomic built-in in g() is not even though both should be. The problem is simply that due to an oversight, the access warnings lack support for atomic built-ins. $ cat y.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout y.c extern _Atomic char x; void f (void) { long *p = (long*)&x; *p = 0; } void g (void) { long *p = (long*)&x; __atomic_store_n (p, 0, 0); } y.c: In function ‘f’: y.c:7:3: warning: array subscript ‘long int[0]’ is partly outside array bounds of ‘_Atomic char[1]’ [-Warray-bounds] 7 | *p = 0; | ^~ y.c:1:21: note: object ‘x’ of size 1 1 | extern _Atomic char x; | ^ ;; Function f (f, funcdef_no=0, decl_uid=1979, cgraph_uid=1, symbol_order=0) void f () { <bb 2> [local count: 1073741824]: MEM[(long int *)&x] = 0; return; } ;; Function g (g, funcdef_no=1, decl_uid=1983, cgraph_uid=2, symbol_order=1) void g () { <bb 2> [local count: 1073741824]: __atomic_store_8 (&x, 0, 0); [tail call] return; }