[libcxx-commits] [PATCH] D145376: [libc++] add declval failure assertion for instantiation
Eric Fiselier via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 8 12:20:26 PST 2023
EricWF added a comment.
Why?
We went out of our way to make `declval` as low cost as we possibly could. Adding a body for the compiler to see is just work.
In D145376#4176608 <https://reviews.llvm.org/D145376#4176608>, @fsb4000 wrote:
> @EricWF
>
> What do you mean?
>
> The change is correct.
>
> You mean gcc and clang compiler frontends have bugs?
>
> By the way libstdc++ has the static_assert since Nov 13, 2009 (https://github.com/gcc-mirror/gcc/commit/7274deff738213914a31413a9d1a671020694175)
>
> and GCC failed "error: static assertion failed: declval() must not be used!"
>
> https://gcc.godbolt.org/z/MssGMMqsd
>
> I see that MSVC works with that example: https://gcc.godbolt.org/z/cjE8dard7
>
> However it has the same library implementation...
Cool. Thanks for the archaeology. But even if they're bugs, it means we break code. So this change isn't going anywhere as-is until
the different compilers converge on a behavior.
In the meantime, If you want to produce a better diagnostics in cases where the thing is ODR used, you can use the `__attribute__((unavailable))` to do that.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145376/new/
https://reviews.llvm.org/D145376
More information about the libcxx-commits
mailing list