http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56468
Bug #: 56468 Summary: Clang exposes bug with unexpected forward-declaration of type_info Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: d.f...@gmx.de The following program fails to compile with Clang++ 3.2: #include <typeinfo> #include <exception> const char* get_name( const std::exception_ptr eptr ) { return eptr.__cxa_exception_type()->name(); } int main() {} The output in the shell is: $ g++-4.7 -std=c++0x -O3 -Wall -Wextra t.cc -o t $ clang++-3.2 -std=c++0x -O3 -Wall -Wextra t.cc -o t t.cc:6:37: error: member access into incomplete type 'const class type_info' return eptr.__cxa_exception_type()->name(); ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/exception_ptr.h:144:19: note: forward declaration of 'std::__exception_ptr::type_info' const class type_info* ^ 1 error generated. $ The problem is that <typeinfo> includes <exception> before it forward-declares std::type_info. In <exception>, type_info is used in the context of std::__exception_ptr, thus Clang generates an implicit forward-declaration for std::__exception_ptr::type_info and, when used in the above code, consequently fails. Further discussion has taken place at <http://stackoverflow.com/q/15098174>.