Ahh, ok. With these explanation I understand that the compiler does remove it 
because of optimatizion. This is somehow good and bad.  Good that unused 
variable does not consume any memory. Bad that developer is not informed that 
variable can be removed.
-------- Ursprüngliche Nachricht --------Von: Jakub Jelinek <ja...@redhat.com> 
Datum: 09.12.20  11:00  (GMT+01:00) An: David Brown <da...@westcontrol.com> Cc: 
webmaster <webmas...@defcon-cc.org>, gcc@gcc.gnu.org Betreff: Re: No warning 
for module global variable which is set but never used On Wed, Dec 09, 2020 at 
10:50:22AM +0100, David Brown wrote:> I'd say that it makes sense to have such 
a warning as a natural> enhancement to the existing "-Wunused-but-set-variable" 
warning.  But IThat is not really possible.The -Wunused-but-set-* warning works 
by having two bits for the DECL,TREE_USED and DECL_READ_P, where any uses mark 
the var TREE_USED and(conservatively) what can read the value marks it 
DECL_READ_Pand -Wunused-but-set-* is then variables that are TREE_USED 
and!DECL_READ_P.  All this needs to be done early in the FE.For the static 
vars, the optimization to remove them altogether is donemuch later, and at that 
point the compiler doesn't know if it isn't usedbecause all the reads in the 
program have been optimized away vs. there werenone.     Jakub

Reply via email to