[ ... ]
Exotic platforms have integrals with padding (I think only
the unsigned ones are allowed to that, the signed ones
should not).
Not so. If a signed and unsigned have the same value, they're
also required to have the same representation, so if there are
padding bits in one, there must be corresponding padding bits
in the other.
The intent, obviously, is that you can pass a possitive int to a
"%x" formating specifier in printf, and not have undefined
behavior.
[ ... ]
Well first of all there are some guarantees from the
standard. The standard says that the unsigned integral
values (that is even for the signed types, if we store a
value without sign) a C++ implementation will use a pure
binary system. To store negative values the standard allows
3 representations 2's complement, 1's complement and sign
and magnitude. All these negative value implementations (you
can look them up on wikipedia or your student textbook) use
a single bit for the sign.
These restrictions are valid for C99, but not (AFAIK) for the
current C++ standard. Though I've never seen or heard of it, I
believe the current C++ standard would allow other pure binary
representations of signed numbers (e.g. a biased
representation).
Maybe, if it could do so and still ensure that the common subset
of values in the signed and unsigned integral type had the same
representation
. (Actually, I don't think it can; I think
that the requirement for a "pure binary representation" holds
for both signed and unsigned. But even if it doesn't, the
requirement you mentionned above ensures that at least the
positive values be represented in pure binary.)
Then again, this restriction was added to C99
largely because there doesn't seem to be any reason NOT to --
i.e. no hardware out there using any representation but those
three, so worrying about seeing something else is probably
pretty pointless.
Also because it was felt that the original wording wasn't very
clear and precise. while I don't think everyone really liked
the idea of enumerating all possible representations, no one
proposed wording which was precise enough to specify what was
wanted otherwise. There's a proposal to adopt the wording from
the C99 standard into C++, which I suppose the committee is
discussing at the meeting this week.