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]

Re: dubious warning about unused object


> [Mark and Martin: I'm just cc'ing you to get some input on this question.
> That's also why I quote a more than I would normally do]

The standard answer to this question refers to the documentation

`-Wunused'
     Warn whenever a variable is unused aside from its declaration,
     whenever a function is declared static but never defined, whenever
     a label is declared but not used, and whenever a statement
     computes a result that is explicitly not used.

     In order to get a warning about an unused function parameter, you
     must specify both `-W' and `-Wunused'.

     To suppress this warning for an expression, simply cast it to
     void.  For unused variables and parameters, use the `unused'
     attribute (*note Variable Attributes::.).

Without seeing the source, I'd assume that g++ behaves as documented:
The variable is not used "aside from its declaration". The
documentation also offers a way to avoid the warning: Use the
__attribute__ extension.

People often think this is 'wrong'. Well, it works as documented, so
it is not wrong. Maybe it is not useful - then don't use the warning.

Hope this helps,
Martin


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