This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


1968. Address of typeid in constant expressions

Section: 7.7  [expr.const]     Status: NAD     Submitter: Richard Smith     Date: 2014-07-14

There is implementation divergence on the handling of typeid in constant expressions, for example:

  static_assert(&typeid(int) == &typeid(int), ""); // #1

According to the current wording, it is unspecified whether two evaluations of the typeid operator produce the same result, even though typeid can be used in constant expressions as long as its operand is not a glvalue of a polymorphic class type. Of particular concern is the case where typeid might be evaluated in different translation units.

Rationale (November, 2014):

Because the result of two separate evaluations of the typeid operator are not guaranteed to produce the same result, the comparison in the example is not permitted in a constant expression.