https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101300
Bug ID: 101300 Summary: -fsanitize=undefined suppresses -Wuninitialized Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: llvm at rifkin dot dev CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- The following code should produce a Wuninitialized warning. int foo() { int n = 4; char b[n]; return b[2]; } The compiler identifies the uninitialized access when compiled -Wall however it does not when compiled with -Wall -fsanitize=undefined. It does warn properly when compiled with -Wall -fsanitize=undefined -O1 (or any optimization flag other than -O0). https://godbolt.org/z/4rrKK5MYj