News for hackers. Stuff that matters.
Re:An Incoherent Rust by debugnik on Tuesday March 24, 2026 @04:12AM (#47499829)
That's a conversion, not the same. The naive equivalent to transmute would be

    int8_t x = 2;
    bool y = *reinterpret_cast<bool *>(&x);
But reinterpret_cast isn't valid in a constexpr scope.
Re:An Incoherent Rust by poppadom1982 on Tuesday March 24, 2026 @04:30AM (#47499924)
My point is, in your exact example both reinterpret_cast and C-style casts have the exact same behavior, making the example bad. If you want to showcase a deficiency of C++, it would make sense to pick something where the difference between cast types actually matters.
Re:An Incoherent Rust by TuxSH on Tuesday March 24, 2026 @05:45AM (#47500396)
> But reinterpret_cast isn't valid in a constexpr scope.

std::bit_cast is

Re:An Incoherent Rust by debugnik on Tuesday March 24, 2026 @05:55AM (#47500467)
Oh cool, and it behaves like memcpy, not like pointer aliasing! I'm stuck with C++14 at work so I missed that one.