On Tue, Feb 17, 2026 at 06:40:54PM -0500, Marek Polacek wrote:
> Good point, I guess the built-in should be checked too. Let's check
> it in the front end then (if I kept the static_assert, we'd complain
> twice). Thanks.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
>
> -- >8 --
> [bit.cast]/2: Mandates: Neither To nor From are consteval-only types
>
> but we are not checking this, so the attached test compiled. I'm
> adding the check into cp_build_bit_cast rather than <bit> so that
> we detect this even for __builtin_bit_cast.
>
> PR c++/124096
>
> gcc/cp/ChangeLog:
>
> * semantics.cc (cp_build_bit_cast): Check that neither argument is
> consteval-only.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/reflect/bit_cast.C: New test.
LGTM.
Jakub