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: [email protected]
ReportedBy: [email protected]
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);
}