------- Comment #2 from jakub at gcc dot gnu dot org 2010-05-14 07:25 ------- Perhaps we just shouldn't ever warn for TREE_CONSTANT decls with -Wunused-but-set-* ? Such variables can't be ever set (the set is just the definition), therefore all sets of TREE_USED for them are reads. That said, it would be good to find out why we don't warn in that case; for [M_CONST + 6] we do warn. Or for DECL_INTEGRAL_CONSTANT_VAR_P decls, or for decls for which integral_constant_value (decl) != decl not sure what is best. In any case, compute_array_index_type (and probably many other spots) calls integral_constant_value and thus doesn't see the passed in decl anymore afterwards.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108