Clang reject type_info as incomplete although <typeinfo> is included

我的未来我决定 提交于 2019-12-05 08:07:13

Thanks to @HowardHinnant's comment, I managed to fix the problem. The problem became obvious in the preprocessor output: libstdc++ includes <exception> from <type_info> before it even declared std::type_info. That made Clang assume a new forward-declaration std::__exception_ptr::type_info. The solution is as simple as it is illegal:

namespace std { class type_info; }

#include <typeinfo>
#include <exception>

const char* get_name( const std::exception_ptr eptr )
{
  return eptr.__cxa_exception_type()->name();
}

int main() {}

Seems like I should check if libstdc++ already has a bug report for that and, if not, create one.

UPDATE: Bug #56468 is now fixed for GCC 4.7.3+

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!