[libcxx-commits] [PATCH] D111197: [libc++] Verify span and string_view are trivially copyable
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 6 10:57:57 PDT 2021
Quuxplusone added inline comments.
================
Comment at: libcxx/test/std/strings/string.view/trivially_copyable.compile.pass.cpp:9
+
+// <string_view>
+
----------------
ldionne wrote:
> jloser wrote:
> > Mordante wrote:
> > > Mordante wrote:
> > > > jloser wrote:
> > > > > Quuxplusone wrote:
> > > > > > This surely needs some `// UNSUPPORTED: c++03, c++11, c++14`, but buildkite will tell you for sure.
> > > > > > ...Actually, it looks like libc++ supports `string_view` as an extension all the way back to C++03? is that true? So you'll want to use `static_assert(std::is_trivially_copyable<...>::value, "");` below.
> > > > > Seems to be the case that `libc++` supports `string_view` all the way back to C++03 oddly enough. Just fixed up the `static_assert`s to play nicely with older modes.
> > > > libc++ originally "back-ported" several features to older standards. This gives us occasionally additional maintenance work. Nowadays we no longer back-port features.
> > > I wonder whether we should disable the test on older versions. This test will fail on MSVC STL in C++11 mode. Looking at cppreference.com I expect other implementations to be trivially copyable from the start.
> > I'd be OK marking this test as unsupported for all standards except C++23.
> Here's what I suggest:
>
> ```
> // P2251 was voted into C++23, but libc++ guarantees triviality in all Standard modes,
> // so we enable the test in all Standard modes for libc++.
> // UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14 || c++17 || c++20)
> ```
>
> Not the prettiest `UNSUPPORTED` annotation I've seen, but it does the job.
If we really care about `!stdlib=libc++` cases that hypothetically might not have backported this fix, then shouldn't we also start caring about `!stdlib=libc++` cases that don't support `string_view` in C++11 or C++14 at all?
I think we should just be simple and aggressive with both of these tests, and then if someone actually turns up a third-party library that fails these tests, //then// we can PR how to disable them.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111197/new/
https://reviews.llvm.org/D111197
More information about the libcxx-commits
mailing list