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

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 26 06:33:29 PDT 2023


ldionne commandeered this revision.
ldionne edited reviewers, added: fsb4000; removed: ldionne.
ldionne added a comment.

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

> Is this code ODR used? I suspect it is, and so it's not valid, but I'm not sure and I ran into a bunch of different instances of this pattern while testing this change.
>
>   template <class T>
>   decltype(auto) compute_return_type() {
>       // ...
>       // stuff that makes this function look reasonable...
>       // ...
>       return std::declval<T>();
>   }
>   
>   using MyT = decltype(compute_return_type<int>());

Yeah, that code would be invalid because `declval()` is ODR used IIUC.

Commandeering to finish as part of the GH PR Transition.


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

https://reviews.llvm.org/D145376



More information about the libcxx-commits mailing list