https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102722
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Target| |sparc-sun-solaris2.11 Status|UNCONFIRMED |RESOLVED Last reconfirmed| |2021-12-16 CC| |msebor at gcc dot gnu.org Host|x86_64-pc-linux-gnu | --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The underlying problem behind the fails/xfails in the test boils down to pr101475. Here's a small test case that shows what's going on. With an x86_64 native GCC 12 -Wstringop-overflow triggers for the overflow in fa4() but not for the one in fa3(). The reason is the difference in the IL (the expected instances of the warning are issued from tree-ssa-strlen.c): GCC 12 handles the vectorized assignment in the latter but not the form in fa3(). The reason for the missing warning is that for COMPONENT_REF, compute_objsize() only considers the size of the sobobject and not also that of the complete object (like the underlying buffer). $ cat pr102722.c && gcc -O2 -S -fdump-tree-strlen=/dev/stdout pr102722.c typedef struct AC3 { char a[3]; } AC3; typedef struct AC4 { char a[4]; } AC4; extern char a1[1]; void fa3 (void) { *(AC3*)a1 = (AC3) { 0, 1, 2 }; // { dg-warning "-Wstringop-overflow" } } void fa4 (void) { *(AC4*)a1 = (AC4) { 0, 1, 2, 3 }; // { dg-warning "-Wstringop-overflow" } } ;; Function fa3 (fa3, funcdef_no=0, decl_uid=1985, cgraph_uid=1, symbol_order=0) ;; 1 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 ;; 2 succs { 1 } void fa3 () { <bb 2> [local count: 1073741824]: MEM[(struct AC3 *)&a1].a[0] = 0; MEM[(struct AC3 *)&a1].a[1] = 1; MEM[(struct AC3 *)&a1].a[2] = 2; return; } ;; Function fa4 (fa4, funcdef_no=1, decl_uid=1989, cgraph_uid=2, symbol_order=1) ;; 1 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 ;; 2 succs { 1 } pr102722.c: In function ‘fa4’: pr102722.c:13:13: warning: writing 4 bytes into a region of size 1 [-Wstringop-overflow=] 13 | *(AC4*)a1 = (AC4) { 0, 1, 2, 3 }; // { dg-warning "-Wstringop-overflow" } | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ pr102722.c:4:13: note: destination object ‘a1’ of size 1 4 | extern char a1[1]; | ^~ void fa4 () { char * vectp.10; vector(4) char * vectp_a1.9; <bb 2> [local count: 1073741824]: MEM <vector(4) char> [(char *)&a1] = { 0, 1, 2, 3 }; return; } *** This bug has been marked as a duplicate of bug 101475 ***