https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92956
--- Comment #14 from Martin Sebor <msebor at gcc dot gnu.org> --- (In reply to Tobias Burnus from comment #12) The warnings have been enabled by default since _FORTIFY_SOURCE (and Builtin Size Checking) was introduced. Given their severity I don't think we want consider changing the default setting. Splitting up the warning into two wouldn't be a good solution, or even a good workaround, because there's no obvious difference between the source code that is prone to the false positives and code that isn't (as far as users can tell, the code looks the same). LTO is a problem in the sense that it enables a C-only warning for FORTRAN code. But a similar problem also affects C if the warning is disabled via #pragma GCC diagnostic (see below). Incidentally, the converse problem (false negatives) affects -Warray-bounds: out-of-bounds indices aren't diagnosed even when explicitly requested (to see that, replace char with int below). We need to come up with a solution to avoid diagnosing code that's synthesized by GCC itself (without introducing false negatives), and we need to get the warning suppression working reliably. With and without LTO. I'm planning to look into the #pragma problem in January but I'm not sure coming up with a solution for the the other problem is feasible in GCC 10. $ cat a.c && gcc -O2 -flto -c -o a1.o a.c && gcc -DMAIN -O2 -flto -c -o a2.o a.c && gcc -O2 -flto a1.o a2.o -o a.out #pragma GCC diagnostic ignored "-Wstringop-overflow" typedef char T; #if MAIN T i; void f (T*); int main (void) { f (&i); return i; } #else void f (T *p) { p[3] = 0; } #endif In function ‘f’, inlined from ‘main’ at a.c:13:3: a.c:21:8: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 21 | p[3] = 0; | ^ a.c: In function ‘main’: a.c:7:3: note: at offset 3 to object ‘i’ with size 1 declared here 7 | T i; | ^