[libcxx-commits] [PATCH] D60666: Fix some constexpr members in array<T, 0>

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 17 08:42:58 PDT 2019


ldionne added inline comments.


================
Comment at: include/array:315
     // element access:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
     reference operator[](size_type) _NOEXCEPT {
----------------
zoecarver wrote:
> ldionne wrote:
> > This can't be marked `constexpr` because it never produces a constant expression.
> You're right. I did not implement/test this properly. There are two things I could do. A) I could remove the `constexpr` from these methods which would make them error at runtime or B) I could add a non-`constexpr` `static_assert` that would fail when one of these methods was used in a program at compile time. I think the later might be UB. Thoughts? 
Honestly, I think the only thing we can do here is to not mark it as `constexpr`. Because there's no way to implement it in a way that it's SOMETIMES a valid constant expression, and the Standard says that it's ill-formed NDR to have a function marked as `constexpr` that can never produce a constant expression.

@EricWF It seems like maybe I should file a LWG issue because the current spec is not implementable, any opinion?


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

https://reviews.llvm.org/D60666





More information about the libcxx-commits mailing list