From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2506 invoked by alias); 10 Dec 2012 23:54:29 -0000 Received: (qmail 2400 invoked by uid 48); 10 Dec 2012 23:54:06 -0000 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55643] [4.7/4.8 Regression] [C++11] incorrect "warning:=?UTF-8?Q?=20variable=20=E2=80=98myVar=E2=80=99=20set=20but=20not=20used?=" with an "enum class"-typed variable is casted to double for the use Date: Mon, 10 Dec 2012 23:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.3 X-Bugzilla-Changed-Fields: Keywords Version Summary Message-ID: In-Reply-To: References: 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 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: 2012-12/txt/msg01053.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55643 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Version|unknown |4.7.2 Summary|[4.7/4.8 Regression] g++ |[4.7/4.8 Regression] |incorrectly prints |[C++11] incorrect |"warning: variable =E2=80=98myVar=E2=80=99 |"warning: = variable =E2=80=98myVar=E2=80=99 |set but not used |set but not used" with an |[-Wunused-but-set-variable] |"enum class"-typed variable |" when an "enum |is casted to double for the |class"-typed variable is |use |cast to double before use | --- Comment #4 from Andrew Pinski 2012-12-10 2= 3:54:04 UTC --- Here is a small testcase without any includes: enum class MyEnum { eSomeValue =3D 123 }; void f(const char*, ...); int main() { MyEnum myVar =3D MyEnum::eSomeValue; // As far as Wunused-but-set-variable is concerned, any of the following // will successfully "use" myVar: // printf("%d\n", myVar); // printf("%d\n", (int)myVar); // printf("%u\n", (unsigned)myVar); // ...but these do not: f("%f\n", (double)myVar); f("%f\n", (float)myVar); return 0; }