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

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 8 12:50:17 PST 2023


Also, I'm not sure a static assert pointing to the stable name in the
standard is helpful to our users. Will they even know what it is?


On Wed, Mar 8, 2023, 3:20 PM Eric Fiselier via Phabricator <
reviews at reviews.llvm.org> wrote:

> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230308/3cdb95e4/attachment.html>


More information about the libcxx-commits mailing list