[libcxx-commits] [libcxx] [libc++] Make std::pair trivially copyable if its members are (PR #89652)

Nico Weber via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 23 07:57:53 PDT 2024


nico wrote:

Before this patch:

```
% cat repro.cc
#include <utility>

struct OpIndex {
  uint32_t offset_;
};

using PhiOp = int;

static_assert(
    std::is_trivially_copyable<std::pair<const PhiOp *, const OpIndex>>::value);
```

```
% clang -c repro.cc -std=c++20 -isystem libcxx/include -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -I ~/src/chrome/src/buildtools/third_party/libc++/ -nostdinc++
```

After this patch:

```
 % clang -c repro.cc -std=c++20 -isystem libcxx/include -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -I ~/src/chrome/src/buildtools/third_party/libc++/ -nostdinc++
repro.cc:9:1: error: static assertion failed due to requirement 'std::is_trivially_copyable<std::pair<const int *, const OpIndex>>::value'
static_assert(
^
1 error generated.
```

Is this expected?

(The `-I` flag is just to pick up a __config_site and an __assertion_handler. I'm attaching both; they should both be pretty vanilla. GitHub won't let me attach them as-is, so here they are zipped up: [Archive.zip](https://github.com/user-attachments/files/16350710/Archive.zip))

https://github.com/llvm/llvm-project/pull/89652


More information about the libcxx-commits mailing list