public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10416: 'unused variable' warning ignores ctor/dtor side-effects
@ 2003-04-16 23:15 bangerth
0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-04-16 23:15 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, gccbugs, nobody
Synopsis: 'unused variable' warning ignores ctor/dtor side-effects
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Wed Apr 16 23:15:53 2003
State-Changed-Why:
The compiler cannot know what you want. If you don't like
the warning, switch it off, or follow what the manual
says:
@item -Wunused-variable
@opindex Wunused-variable
Warn whenever a local variable or non-constant static variable is unused
aside from its declaration
To suppress this warning use the @samp{unused} attribute
(@pxref{Variable Attributes}).
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10416
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/10416: 'unused variable' warning ignores ctor/dtor side-effects
@ 2003-04-15 18:56 gccbugs
0 siblings, 0 replies; 2+ messages in thread
From: gccbugs @ 2003-04-15 18:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 10416
>Category: c++
>Synopsis: 'unused variable' warning ignores ctor/dtor side-effects
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: pessimizes-code
>Submitter-Id: net
>Arrival-Date: Tue Apr 15 18:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Eelis van der Weegen
>Release: gcc 3.2
>Organization:
>Environment:
>Description:
Sometimes a variable is created only for the side-effects of its constructor/destructor. For example, in the following code:
struct Closer { ~Closer() { CloseClipboard(); } } closer;
the closer variable is only used to make sure the clipboard is closed when the function leaves (normally or exceptionally).
G++ apparently does not think this is valid use of a variable, and warns: "warning: unused variable".
>How-To-Repeat:
Compile:
void f () { struct atend { ~atend () { std::cout << "leaving f\n"; } } a; }
with -Wall.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-04-16 23:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-16 23:15 c++/10416: 'unused variable' warning ignores ctor/dtor side-effects bangerth
-- strict thread matches above, loose matches on Subject: below --
2003-04-15 18:56 gccbugs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).