From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15248 invoked by alias); 23 Jan 2006 22:23:16 -0000 Received: (qmail 15183 invoked by uid 48); 23 Jan 2006 22:23:14 -0000 Date: Mon, 23 Jan 2006 22:23:00 -0000 Message-ID: <20060123222314.15182.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/10416] 'unused variable' warning ignores ctor/dtor side-effects In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pinskia at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-01/txt/msg02503.txt.bz2 List-Id: ------- Comment #10 from pinskia at gcc dot gnu dot org 2006-01-23 22:23 ------- (In reply to comment #9) > Of course, the compiler (more precisely the middle-end) knows that the > destructor has a side-effect. But GCC middle-end tends to have little > knowledge of language specific idioms. Notice also that a is "used" > from a very high level abstraction point of view -- not from byte-fiddling > point of view. This is another instance of diagnostic PR better handed off > to the front-end. Actually the diagnostic is done in the front-end in cp/decl.c in poplevel. /* Before we remove the declarations first check for unused variables. */ if (warn_unused_variable && !processing_template_decl) for (decl = getdecls (); decl; decl = TREE_CHAIN (decl)) if (TREE_CODE (decl) == VAR_DECL && ! TREE_USED (decl) && ! DECL_IN_SYSTEM_HEADER (decl) && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) warning (0, "unused variable %q+D", decl); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10416