Title
Address of typeid in constant expressions
Status
nad
Section
7.7 [expr.const]
Submitter
Richard Smith

Created on 2014-07-14.00:00:00 last changed 114 months ago

Messages

Date: 2014-11-15.00:00:00

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.

Date: 2022-11-20.07:54:16

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.

History
Date User Action Args
2014-11-24 00:00:00adminsetmessages: + msg5272
2014-07-14 00:00:00admincreate