https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93121

--- Comment #12 from Wilhelm M <klaus.doldinger64 at googlemail dot com> ---
The following does not work:

# include <cstdint>
# include <cstring>
# include <cstddef>
# include <bit>
# include <array>

using to_t   = std::array<int16_t, 2>;

int main() {
    constexpr std::byte from1[4]{};
    constexpr auto v1 = std::bit_cast<to_t>(from1);    
    return v1[0];
}

gives:

/usr/local/include/c++/11.0.0/bit: In function 'int main()':
/home/lmeier/Projekte/wmucpp/host/test88.cc:11:50:   in 'constexpr' expansion
of 'std::bit_cast<std::array<short int, 2>, std::byte [4]>(from1)'
/usr/local/include/c++/11.0.0/bit:60:33: sorry, unimplemented:
'__builtin_bit_cast' cannot be constant evaluated because the argument cannot
be encoded
60 |       return __builtin_bit_cast(_To, __from);
|                                 ^~~

Reply via email to