From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7765 invoked by alias); 30 Apr 2014 17:20:20 -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 Received: (qmail 7674 invoked by uid 48); 30 Apr 2014 17:20:15 -0000 From: "michael.chapman at cortus dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/7652] -Wswitch-break : Warn if a switch case falls through Date: Wed, 30 Apr 2014 17:20: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-Version: unknown X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: michael.chapman at cortus dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-04/txt/msg02303.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D7652 --- Comment #33 from Michael Chapman --- (In reply to Florian Weimer from comment #30) > (In reply to Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez from comment #29) >=20 > > I like the previous suggestion of using "goto LABEL;". In fact, the war= ning > > message could explicitly say "use % to silence this warning". >=20 > Does this mean that you propose a GCC extension which allows to write thi= s? >=20 > goto 5; > case 5: >=20 > I'm not sure if the extension is worth it, and it creates another source = of > errors/unclarities if another switch branch is inserted before "case 5:".= =20 > It looks like fall-through, but it isn't one because the case labels aren= 't > aligned. Why an extension? What is wrong with:- goto case_5; case 5: case_5: .... >>From gcc-bugs-return-450284-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Apr 30 17:27:48 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 11494 invoked by alias); 30 Apr 2014 17:27:48 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 11469 invoked by uid 48); 30 Apr 2014 17:27:44 -0000 From: "ppluzhnikov at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61020] New: [4.9/4.10 Regression] typeid(typeid(X)) produces 'ud2' Date: Wed, 30 Apr 2014 17:27:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ppluzhnikov at google dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-04/txt/msg02304.txt.bz2 Content-length: 1275 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61020 Bug ID: 61020 Summary: [4.9/4.10 Regression] typeid(typeid(X)) produces 'ud2' Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ppluzhnikov at google dot com The test case: #include struct Base { virtual ~Base() { } }; struct Derived : public Base { }; int compare(const Base& base) { return typeid(base) == typeid(typeid(Derived)); } int main() { Base base; Derived derived; if (compare(base)) return 1; if (compare(derived)) return 2; return 0; } Using trunk @ r209848 g++ -g t.cc && ./a.out && echo OK OK g++ -g t.cc -O2 && ./a.out Segmentation fault (core dumped) (gdb) disas main Dump of assembler code for function main(): 0x00000000004004c0 <+0>: mov 0x8,%rax 0x00000000004004c8 <+8>: ud2 End of assembler dump. It appears that GCC believes the test to invoke undefined behavior. However, I don't see anything in the standard to support this. P.S. Same result in C++98 and C++11 P.P.S. In the original code, the double application of typeid() was a bug.