public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hordi at ukr dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/49440] New: Invalid dynamic_cast for unnamed namespace
Date: Thu, 16 Jun 2011 13:19:00 -0000	[thread overview]
Message-ID: <bug-49440-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49440

           Summary: Invalid dynamic_cast for unnamed namespace
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hordi@ukr.net


We have a base class, from this base class we are creating two classes in
unnamed namespace (each class in different *.cpp-file). After that we are
creating one from it and trying to dynamic_cast to other - in result this
operation is processed but should not. This code works properly for gcc-4.4.5
for example...

small description:

file: a.h

class Module{...}

Module *gp = 0;

file a.cpp
namespace
{
  class ItemModule : public Module{}
}

some code:
gp = new ItemModule();

file main.cpp
namespace
{
  class ItemModule : public Module{}
}

int main()
{
  ItemModule *p = dynamic_cast<ItemModule*>(gp);

  //I expect to see NULL, but have real address
  printf("%p\n",p);
}


             reply	other threads:[~2011-06-16 13:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 13:19 hordi at ukr dot net [this message]
2011-06-16 13:22 ` [Bug c++/49440] " hordi at ukr dot net
2011-06-16 13:24 ` hordi at ukr dot net
2011-06-22 21:01 ` [Bug c++/49440] [4.5/4.6/4.7 regression] " jason at gcc dot gnu.org
2011-06-23 16:56 ` jason at gcc dot gnu.org
2011-06-27  1:13 ` jason at gcc dot gnu.org
2011-06-27  1:15 ` [Bug c++/49440] [4.6 " jason at gcc dot gnu.org
2011-06-27 20:17 ` jason at gcc dot gnu.org
2011-06-27 20:19 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49440-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).