From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26529 invoked by alias); 15 Apr 2003 18:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 26509 invoked by uid 71); 15 Apr 2003 18:56:00 -0000 Resent-Date: 15 Apr 2003 18:56:00 -0000 Resent-Message-ID: <20030415185600.26508.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, gccbugs@contacts.eelis.net Received: (qmail 19744 invoked by uid 48); 15 Apr 2003 18:47:11 -0000 Message-Id: <20030415184711.19743.qmail@sources.redhat.com> Date: Tue, 15 Apr 2003 18:56:00 -0000 From: gccbugs@contacts.eelis.net Reply-To: gccbugs@contacts.eelis.net To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/10416: 'unused variable' warning ignores ctor/dtor side-effects X-SW-Source: 2003-04/txt/msg00707.txt.bz2 List-Id: >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: