[libcxx-commits] [libcxx] [libc++] Fix constexpr initialization of std::array<T, 0> (PR #74667)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 14 14:53:24 PST 2023


================
@@ -18,26 +18,33 @@ struct NoDefault {
     TEST_CONSTEXPR NoDefault(int) { }
 };
 
-// Test default initialization
-// This one isn't constexpr because omitting to initialize fundamental types
-// isn't valid in a constexpr context.
-struct test_default_initialization {
+struct test_initialization {
----------------
ldionne wrote:

The only reason this was multiple structs previously is basically that I couldn't run the default initialization test in constexpr, so I needed another named struct for it. The way this is written right now follows our usual pattern of having something like:

```
constexpr bool test() {
  // test case 1
  {
    ...
  }
  // test case 2
  {
    ...
  }
  // test case 3
  {
    ...
  }

  return true;
}

int main() {
  test();
  static_assert(test());
}
```

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


More information about the libcxx-commits mailing list