[libcxx-commits] [PATCH] D120951: [libc++] Prepare string tests for constexpr

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 10 14:01:28 PST 2022


Quuxplusone added a comment.

In D120951#3373293 <https://reviews.llvm.org/D120951#3373293>, @philnik wrote:

>> Doesn't this change make all of the tests with functions decorated with TEST_CONSTEXPR_AFTER_CXX20 undefined behavior, since it's undefined to have constexpr on a function that is never constexpr?
>
> @EricWF How could this be undefined bahavior? All the tests are templated on the string, so it's possible to give them a constexpr string.

This is theory versus practice. In theory, it's IFNDR to define a template that //can never// be validly instantiated. But in practice the meaning of "can never" is really unclear: does it mean "is never"? how much imagination does the compiler have to possess here? So in practice, compilers don't check template definitions prior to instantiation, and thus templates are always safe to mark `constexpr`. We're using that practical license here. I don't believe there's any practical problem with what we're doing here, IFNDR-wise. (And within a couple of months even the theoretical question should be moot anyway, right? hopefully?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120951/new/

https://reviews.llvm.org/D120951



More information about the libcxx-commits mailing list