https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65812
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- This changed supposedly with r138933 and from that PR20644 I think it is quite clear this is intentional. The code in foo_2 is conditional (on a condition later proved to be always true, though), so we really don't want to warn on it early, because it might be in dead code, and we don't warn for it late because it really is dead code, optimized away as nothing uses it. If you add say a global void *b; variable and change the a = a; statements to b = a;, then it will warn even when optimizing, as the code won't be dead.