https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101455
Bug ID: 101455 Summary: missing -Wstringop-overflow on buffer overflow by a complex number Product: gcc Version: 11.1.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 store in the function below overflows the buffer and should be diagnosed by -Wstringop-overflow (which is enabled by default) but isn't. It's only diagnosed by -Warray-bounds (which is included in -Wall). $ cat a.c && gcc -O2 -S -fdump-tree-strlen=/dev/stdout a.c void* f (double x, double i) { _Complex double *p = __builtin_malloc (sizeof (double)); *p = __builtin_complex (x, i); return p; } ;; Function f (f, funcdef_no=0, decl_uid=1944, 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 * f (double x, double i) { complex double * p; <bb 2> [local count: 1073741824]: p_3 = __builtin_malloc (8); REALPART_EXPR <*p_3> = x_4(D); IMAGPART_EXPR <*p_3> = i_5(D); return p_3; }