llvm / llvm/llvm-project

[clang] typeid() can only be used with <typeinfo>

Open
#162,758 3 comments 0 reactions 1 assignee Claimed by @ChuanqiXu9 View on GitHub
clang:modules
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When compiling a translation unit that calls the `typeid()` operator, the compiler will compile the file only if `` is `#include`d. It will not compile when using `import std;` (or any module that re-exports `std::type_info`), for example, without any `#include `.

I imagine this is not intended, as [cppreference](https://en.cppreference.com/w/cpp/language/typeid.html) states that a program is ill-informed if it calls `typeid()` without `std::type_info` being visible, if a translation imports a module that re-exports `std::type_info`, it should in theory still work, yet it does not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.