[libcxx-commits] [PATCH] D145376: [libc++] add declval failure assertion for instantiation

Shafik Yaghmour via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 7 21:36:00 PST 2023


shafik added a comment.

In D145376#4176228 <https://reviews.llvm.org/D145376#4176228>, @EricWF wrote:

> This change is not correct and cannot proceed.
>
> It changes the meaning of this code:
>
>   template <class T, class U, class = U[std::declval<T>()]>
>   constexpr bool xxx(int) { return true; }
>   
>   template <class T, class U>
>   constexpr bool xxx(long) { return false; }
>   
>   constexpr bool y = xxx<long long, int>(0);
>
> declval has been constructed very carefully to performant, and correct in all the weird cases where Clang will try to eagerly instantiate something (Ex. when it tries to check for C++11 narrowing when evaluating constant expressions).
> Please be cautious when modifying weird things like declval.

Thank you for catching this, I am hoping that we have test for these edge cases, if not do you think you can enumerate more of them so that we can ensure that we are doing the right thing.


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

https://reviews.llvm.org/D145376



More information about the libcxx-commits mailing list