[libcxx-commits] [libcxx] [libc++] Add a test case for std::bit_cast with std::complex (PR #97751)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 4 09:12:35 PDT 2024
================
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Make sure that std::bit_cast works with std::complex. Test case extracted from
+// https://github.com/llvm/llvm-project/issues/94620.
+
+#include <bit>
+#include <complex>
+
+template <class T>
+constexpr void test() {
+ using Complex = std::complex<T>;
+ unsigned char data[sizeof(Complex)] = {0};
+
+ Complex c = std::bit_cast<Complex>(data);
+ (void)c;
----------------
mordante wrote:
```suggestion
[[maybe_unused]] Complex c = std::bit_cast<Complex>(data);
```
https://github.com/llvm/llvm-project/pull/97751
More information about the libcxx-commits
mailing list