https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94545
--- Comment #5 from Thomas Mercier <thomas.mercier.jr at gmail dot com> --- (In reply to Jonathan Wakely from comment #3) > (In reply to Thomas Mercier from comment #2) > > I thought that might be the response. Then why does it compile? > > Because the standard requires it to. > > > The fact that it does, and produces a result is surprising. > > I don't know what the standard says, > > You should look. It's very explicit: > > "The default numeric_limits<T> template shall have all members, but with 0 > or false values." > > The standard is clear about what the primary template does, and is clear > that there is no specialization for std::byte. > > std::byte is not a numeric type, why do you expect std::numeric_limits to be > meaningful for it? > > If you want the value with all bits set, use ~std::byte(). Yeah paywalled unfortunately. :\ I since found the section you quote in a draft document. I don't have a problem with std::byte being a non-arithmetic type, but that didn't occur to me as I was first writing the code. The behavior of the primary template is what is surprising... and entirely compliant as you point out.