This is the mail archive of the gcc-bugs@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]

[Bug c++/71402] -Wunused-variable warnings ignore initialization side effects


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71402

--- Comment #4 from andysem at mail dot ru ---
(In reply to Martin Sebor from comment #2)
> I just happened to be looking into this report and it's not clear to me
> whether or not the warning should be expected in this case.  The
> documentation suggests it should be:
> 
> -Wunused-variable
>     Warn whenever a local or static variable is unused aside from its
> declaration.

For the record, I think the warning should not be emitted in the case I
presented in this bug. Yes, the variable itself is not used anywhere beside its
declaration, but nonetheless the declaration is not useless (i.e. its whole
point is to invoke the dynamic initialization). I think the documentation
should be updated to reflect that the warning should not be emitted when the
variable declaration involves dynamic initialization with possible side
effects.

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