This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/49440] New: Invalid dynamic_cast for unnamed namespace


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);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]