https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109476
--- Comment #6 from Wilhelm M <klaus.doldinger64 at googlemail dot com> ---
The following "solution"
constexpr uint16_t mul(const uint8_t a, const uint16_t b) {
const auto aa = std::bit_cast<std::array<uint8_t, 2>>(b);
return aa[1] * a;
}
or
constexpr uint16_t mul(const uint8_t a, const uint16_t b) {
uint8_t aa[2];
std::memcpy(aa, &b, 2);
return aa[1] * a;
}
gives optimal result ;-)
