This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20647] New: Wrong typeid for incomplete types
- From: "frederic dot riss at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Mar 2005 15:46:41 -0000
- Subject: [Bug c++/20647] New: Wrong typeid for incomplete types
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
On linux x86, using the following 2 little sources files :
---------- 1.C --------------------
#include <typeinfo>
class A {
public:
A() {}
};
extern void foo(const std::type_info&);
int main()
{
foo(typeid(A*));
return 0;
}
-----------------------------------
---------- 2.C --------------------
#include <iostream>
#include <typeinfo>
class A;
void foo(const std::type_info& t)
{
if (t == typeid(A*))
{
std::cout << "OK\n";
}
else
{
std::cout << "KO\n";
}
}
-----------------------------------
and compiling with "g++ 1.C 2.C" gives me KO output. This means that the
comparison of the type_info passed to foo and the one computed by typeid(A*)
where A* is an incomplete type failed.
In the binary there are 2 type_info symbols for A* :
% nm a.out| grep TIP1A
0804884c r _ZTIP1A
0804882c V _ZTIP1A
I tried this test with many compilers and it worked with g++ 3.2 and failed with
g++ 3.3, 3.4 and pre4.0 (with the same binutils). Precise versions :
% gcc-3.2 --version
gcc-3.2 (GCC) 3.2.3 (Debian)
% gcc-3.3 --version
gcc-3.3 (GCC) 3.3.5 (Debian 1:3.3.5-8ubuntu2)
% gcc-3.4 --version
gcc-3.4 (GCC) 3.4.4 20050209 (prerelease) (Debian 3.4.3-9ubuntu3)
% gcc-4.0 --version
gcc-4.0 (GCC) 4.0.0 20050301 (prerelease) (Debian 4.0-0pre6ubuntu6)
--
Summary: Wrong typeid for incomplete types
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: frederic dot riss at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20647