This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] MSVC does not provide constexpr for typeid and typeid is probably not constexpr
AbandonedPublic

Authored by danlark on Feb 10 2019, 8:54 PM.

Details

Summary

Actually, there is nothing about constexpr qualifier for typeid operator in the standard and MSVC is probably correct in this case.

I can be wrong and if you convince me that typeid should be constexpr, I would discard this review and submit a bug to the Microsoft compiler team

Diff Detail

Event Timeline

danlark created this revision.Feb 10 2019, 8:54 PM
danlark updated this revision to Diff 186185.Feb 10 2019, 9:35 PM
danlark retitled this revision from MSVC does not provide constexpr for typeid and typeid is probably not constexpr to [libcxx] MSVC does not provide constexpr for typeid and typeid is probably not constexpr.
EricWF requested changes to this revision.Feb 10 2019, 10:27 PM

MSVC is wrong and this code is well formed. Please file a bug with MSVC.
The wording is somewhere in [expr.const].

The value of the typeid object isn't usable in a constant expression, but the address of the typeid object is. Similarly.

void test() {
  static int x = rand();
  constexpr int& y = x; // OK
 static_assert(&y); // OK
 static_assert(y); // BOOM!;
}

The constexpr here is important to ensuring that the __policy_ variable has a constant initializer and therefore doesn't need or emit a guard variable.

This revision now requires changes to proceed.Feb 10 2019, 10:27 PM
danlark abandoned this revision.Feb 11 2019, 12:33 AM