[Bug c/44677] Warn for variables incremented but not used

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 4 19:01:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44677

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #6)
> I haven't thought through the implementation challenges but defining the
> extended -Wunused-but-set-variabl rule that's being suggested here seems
> straightforward: every write to an object must be followed by another access
> to it (either read or write).  If not, it's diagnosed.

That is not straightforward at all.  The FE doesn't have IL on which it can
analyze write accesses being followed by something (no cfg, no SSA form), and
in the middle end it is way too late for such a warning (because as soon as you
optimize away something, you could optimize away those reads and warning just
because the optimizers managed to optimize away some use are not really
helpful).


More information about the Gcc-bugs mailing list