https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105084
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Neither is false positive, both are real bugs in your test programs. The fact that on the second testcase a violation isn't reported at -O0 and is at -O2 depends on the ordering of the global variables (we emit a then b for -O0 and b then a for -O2). We only emit the red zones after each variable, not both before and after each var, because that would waste too much memory especially in programs that use a lot of translation units and very few global vars in each. If all the translation units in a program (or shared library) are compiled with -fsanitize=address, the net effect is that underflows for the first variable (probably in each section variables are present) aren't detected, when mixing -fsanitize=address and non-sanitized objects it can result in more underflows not being detected.