← Back to context

Comment by Maxatar

17 hours ago

There's no guarantee char8_t is 8 bits either, it's only guaranteed to be at least 8 bits.

> There's no guarantee char8_t is 8 bits either, it's only guaranteed to be at least 8 bits.

Have you read the standard? It says: "The result of sizeof applied to any of the narrow character types is 1." Here, "narrow character types" means char and char8_t. So technically they aren't guaranteed to be 8 bits, but they are guaranteed to be one byte.

  • Yes, but the byte is not guaranteed to be 8 bits, because on many ancient computers it wasn't.

    The poster to whom you have replied has read correctly the standard.

What platforms have char8_t as more than 8 bits?

  • Well platforms with CHAR_BIT != 8. In c and c++ char and there for byte is atleast 8 bytes not 8 bytes. POSIX does force CHAR_BIT == 8. I think only place is in embeded and that to some DSPs or ASICs like device. So in practice most code will break on those platforms and they are very rare. But they are still technically supported by c and c++ std. Similarly how c still suported non 2's complement arch till 2023.