From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29442 invoked by alias); 5 Oct 2010 12:48:42 -0000 Received: (qmail 29434 invoked by uid 22791); 5 Oct 2010 12:48:41 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Oct 2010 12:48:37 +0000 From: "nicola at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug objc/45895] New: -Wunused-but-set-variable complains for almost all Objective-C objects X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: objc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nicola at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Tue, 05 Oct 2010 12:48:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg00396.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D45895 Summary: -Wunused-but-set-variable complains for almost all Objective-C objects Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: objc AssignedTo: unassigned@gcc.gnu.org ReportedBy: nicola@gcc.gnu.org It seems that -Wunused-but-set-variable complains any time an Objective-C object variable is set, and only used to invoke methods. This is incorrect; when a variable is used to invoke a method, it is used. :-) (hence, compiling any Objective-C with -Wall generates lots of wrong warnin= gs). Here is a testcase -- #include #include int main (void) { id o =3D nil; [o hash]; return 0; } Here are what happens when you compile: [nicola@lampone ~]$ gcc -Wall bug.m -lobjc -c bug.m: In function =E2=80=98main=E2=80=99: bug.m:6:6: warning: variable =E2=80=98o=E2=80=99 set but not used [-Wunused= -but-set-variable] [nicola@lampone ~]$=20 The warning is obviously incorrect because 'o' *is* used. This is on a i686-pc-linux-gnu. Thanks