This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC warnings for unused global variables


It seems to me that an important goal of software tools is to facilitate
writing software.  Writing software is hard enough without extra impediments.
Is this warning accomplishing that goal?  Well, what are the costs and benefits?

Cost: hundreds of thousands (millions?) of existing source modules will either
      have to change, ignore this warning, not be compilable by current GCC,
      or loose the benefit of -Wall.

Benefit: sloppily patched programs will be marked as having squandered tens,
      hundreds or even thousands of bytes of memory that apparently might
      get optimized away anyway (assuming it isn't marked 'volatile').

I really think that pretty much clarifies what is more important.
Nevertheless, it is still possible to set -Wall and then suppress
specific warnings, right?  So why such a big deal?


WRT volatile:

> | Accessing a volatile object includes writing, and writing includes
> | initializing.  So the initialization cannot be optimized out.
> 
> Why? the last part of the paragraph quoted above does specifically
> permit that optimization where applicable.

Here's the main deal:  you'll violate a reasonable interpretation
that will make life hard for programmers just because of a, well,
unusual interpretation of the wording.   REMEMBER:  you are trying
to help programmers accomplish their task.  You are not trying to
cause grief just because the law of the C language left a hole
allowing you to whack 'em.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]