Date: Fri, 6 Feb 2026 14:17:45 -0600
On Fri, Feb 6, 2026, 2:14 PM Keenan Horrigan via Std-Discussion <
std-discussion_at_[hidden]> wrote:
> I was playing around with the C++26 reflection stuff a bit, and realized
> that since std::meta::info is a scalar type, and all scalar types are
> trivially-copyable, then std::meta::info should be trivially-copyable and
> therefore bit_castable.
>
> Of course I have no real idea what that would actually result in, and
> indeed currently GCC trunk raises an error and says that it is
> unimplemented:
>
> /cefs/55/552701a8be9eb5ce4ab990a8_gcc-trunk-20260206/include/c++/16.0.1/bit:
> In function 'int main()':
> in 'constexpr' expansion of 'std::bit_cast<array<char, 8>,
> std::meta::info>(info)'
> <source>:7:63:
> 7 | constexpr auto casted = std::bit_cast<std::array<char,
> 8>>(info);
> |
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
> /cefs/55/552701a8be9eb5ce4ab990a8_gcc-trunk-20260206/include/c++/16.0.1/bit:96:33:
> sorry, unimplemented: '__builtin_bit_cast' cannot be constant evaluated
> because the argument cannot be encoded
> 96 | return __builtin_bit_cast(_To, __from);
> | ^~~
>
> Theoretically as well, it could only be done during constant evaluation
> due to std::meta::info being a consteval-only type.
>
> I suppose it might come down to what is the "value representation" of a
> std::meta::info, which I believe is implementation-defined. But then even
> at the extreme, if it were somehow that there are zero bits in the value
> representation of a std::meta::info, then I believe it should just yield a
> sequence of indeterminate bytes in that case, no? Though looking at
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99637 it seems there may be
> some question as to whether that should still result in an error, anyways.
>
> But regardless, is this a gap in the standard? It doesn't appear very
> meaningful either way, but I'm curious.
>
> Thanks
>
No, it's explicitly not bit-cast-able. Neither the source nor destination
type is allowed to be consteval-only: https://eel.is/c++draft/bit.cast#2
Barry
std-discussion_at_[hidden]> wrote:
> I was playing around with the C++26 reflection stuff a bit, and realized
> that since std::meta::info is a scalar type, and all scalar types are
> trivially-copyable, then std::meta::info should be trivially-copyable and
> therefore bit_castable.
>
> Of course I have no real idea what that would actually result in, and
> indeed currently GCC trunk raises an error and says that it is
> unimplemented:
>
> /cefs/55/552701a8be9eb5ce4ab990a8_gcc-trunk-20260206/include/c++/16.0.1/bit:
> In function 'int main()':
> in 'constexpr' expansion of 'std::bit_cast<array<char, 8>,
> std::meta::info>(info)'
> <source>:7:63:
> 7 | constexpr auto casted = std::bit_cast<std::array<char,
> 8>>(info);
> |
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
> /cefs/55/552701a8be9eb5ce4ab990a8_gcc-trunk-20260206/include/c++/16.0.1/bit:96:33:
> sorry, unimplemented: '__builtin_bit_cast' cannot be constant evaluated
> because the argument cannot be encoded
> 96 | return __builtin_bit_cast(_To, __from);
> | ^~~
>
> Theoretically as well, it could only be done during constant evaluation
> due to std::meta::info being a consteval-only type.
>
> I suppose it might come down to what is the "value representation" of a
> std::meta::info, which I believe is implementation-defined. But then even
> at the extreme, if it were somehow that there are zero bits in the value
> representation of a std::meta::info, then I believe it should just yield a
> sequence of indeterminate bytes in that case, no? Though looking at
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99637 it seems there may be
> some question as to whether that should still result in an error, anyways.
>
> But regardless, is this a gap in the standard? It doesn't appear very
> meaningful either way, but I'm curious.
>
> Thanks
>
No, it's explicitly not bit-cast-able. Neither the source nor destination
type is allowed to be consteval-only: https://eel.is/c++draft/bit.cast#2
Barry
Received on 2026-02-06 20:18:01
