public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57599] New: g++ accepts invalid dynamic_cast of a const type to a regular type
@ 2013-06-12 16:30 abel at gcc dot gnu.org
  2013-06-12 16:35 ` [Bug c++/57599] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: abel at gcc dot gnu.org @ 2013-06-12 16:30 UTC (permalink / raw)
  To: gcc-bugs

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<const A*>(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
*"


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-06-14 10:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-12 16:30 [Bug c++/57599] New: g++ accepts invalid dynamic_cast of a const type to a regular type abel at gcc dot gnu.org
2013-06-12 16:35 ` [Bug c++/57599] " redi at gcc dot gnu.org
2013-06-12 16:38 ` [Bug c++/57599] g++ accepts invalid assignment of a dynamic_cast<const A*> to A* abel at gcc dot gnu.org
2013-06-12 23:34 ` [Bug c++/57599] result of dynamic_cast<cv T> is just T paolo.carlini at oracle dot com
2013-06-13  6:59 ` daniel.kruegler at googlemail dot com
2013-06-13  7:03 ` abel at gcc dot gnu.org
2013-06-14  9:23 ` paolo.carlini at oracle dot com
2013-06-14  9:37 ` abel at gcc dot gnu.org
2013-06-14 10:17 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).