Skip to content

Unsupported constexpr std::bit_cast for std::complex #94620

@Svalorzen

Description

@Svalorzen

Hello, I am trying to bit_cast a structure containing std::complex, and clang is reporting that this is unsupported. I'm attaching here an MVE:

#include <bit>
#include <iostream>
#include <complex>
#include <array>

using C = std::complex<double>;

int main() {
    constexpr unsigned char data[sizeof(C)] = {0};

    constexpr C c = std::bit_cast<C>(data);
    std::cout << c << '\n';

    return 0;
}

This seems to fail on trunk as per godbolt (https://godbolt.org/z/q8fKE7r18).

There exists a similar issue, #54018, with PR #74775, which involves bit-fields. I am not sure whether this is related at low level, but I think enabling std::bit_cast on a "native" standard library type is quite important. I am opening this issue as I have not been able to find any status reports on this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions