[Bug middle-end/31795] New: -Wunused should warn about variables set but never read
ghazi at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu May 3 02:33:00 GMT 2007
Patches like this:
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00059.html
expose a problem with GCC's -Wunused machinery. Namely, that it fails to
detect cases where a variable is set but never read. I'd like GCC to detect
these cases automatically. I think it probably requires auditing everywhere
the TREE_USED flag is set, and splitting it into a TREE_READ vs. a
TREE_ASSIGNED flag. Or something like that. Then we could distinguish these
two cases and issue the appropriate warning for cases like in the above URL.
Seems like there's about 150 "TREE_USED.*=" across the whole source base.
That's a lot, but not insurmountable.
IIRC, the SGI compiler had this ability many years ago. It would be nice IMHO
if we caught up in this regard.
--
Summary: -Wunused should warn about variables set but never read
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ghazi at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31795
More information about the Gcc-bugs
mailing list