This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: eb78
>>>>> Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:
> [unused variable with non-trivial constructor]
>> It should be an expected warning, methinks.
> For 'normal' unused warnings, it means that you can remove the unused
> thing without effecting the semantics. In this case, removing the
> variable will give a different execution.
Yes, but not usefully. We decided in the C++ frontend not to warn about
objects with both constructors and destructors, but objects that don't get
destroyed and are never used should be warned about. Sure, creating a File
has side effects, but that File is never used, so it might as well not have
been created. Thus the warning.
> In that sense, the variable is certainly used in the program, even
> though the warning complies with its documentation. If you want
> strictly to follow that documentation, just put // WARNING in there.
Yep.
Jason