Skip to content

[libc++] Add a test case for std::bit_cast with std::complex #97751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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};

[[maybe_unused]] Complex c = std::bit_cast<Complex>(data);
}

constexpr bool test_all() {
test<float>();
test<double>();
test<long double>();
return true;
}

int main(int, char**) {
test_all();
static_assert(test_all());
return 0;
}
Loading