From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13371 invoked by alias); 12 Jun 2013 16:30:26 -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 13288 invoked by uid 48); 12 Jun 2013 16:30:16 -0000 From: "abel at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57599] New: g++ accepts invalid dynamic_cast of a const type to a regular type Date: Wed, 12 Jun 2013 16:30: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: 4.7.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: abel 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-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: 2013-06/txt/msg00646.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57599 Bug ID: 57599 Summary: g++ accepts invalid dynamic_cast of a const type to a regular type Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: abel at gcc dot gnu.org The following code is accepted by g++ (versions 3.3, 4.6, 4.7 at least, I didn't check trunk) but seems to be invalid c++ and is rejected by clang 3.2, icc 13, msvc 12: class A { }; class B : public A { }; int main() { A* a; B* b = new B(); a = dynamic_cast(b); return 0; } An expected error is along the lines of (icc): error: a value of type "const A *" cannot be assigned to an entity of type "A *"