https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115590
Bug ID: 115590 Summary: Bad dereferences through -> operator not detected by sanitizers Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: nrk at disroot dot org 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 Target Milestone: --- Minimal testcase: int main(void) { struct { int v; } *p = 0; p->v; return 0; } Compile and run with: [/tmp]~> gcc -fsanitize=address,undefined -O0 -o test ./test.c && ./test Doesn't detect the null pointer deref. Same with clang: [/tmp]~> clang -fsanitize=address,undefined -O0 -o test ./test.c && ./test ./test.c:4:5: warning: expression result unused [-Wunused-value] p->v; ~ ^ 1 warning generated. test.c:4:5: runtime error: member access within null pointer of type 'struct (unnamed struct at ./test.c:3:2)' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:4:5 in test.c:4:5: runtime error: load of null pointer of type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:4:5 in