Closed
Description
On this code:
// Build with -std=c++20
#include <typeinfo>
struct base { virtual void enable_vtable(); };
struct derived : base {};
derived d;
static_assert(&typeid(d) == &typeid(derived));
Clang produces the following error:
error: static assertion expression is not an integral constant expression
note: typeid applied to object 'd' whose dynamic type is not constant
Even though typeid
can be computed at compile time (since d
is not a reference and has a concrete object type).
GCC and MSVC compile this code with no errors, see Godbolt.