I
Ioannis Vranos
Under C++03:
Is it guaranteed that char, unsigned char, signed char have no padding bits?
Is it guaranteed that char, unsigned char, signed char have no padding bits?
Ioannis said:Under C++03:
Is it guaranteed that char, unsigned char, signed char have no
padding bits?
Ioannis said:Under C++03:
Is it guaranteed that char, unsigned char, signed char have no padding bits?
3.9.1Victor said:I can find no such guaranteed in the document (you still haven't
got your own copy?)
V
Ron said:Yes, the first paragraph of 3.9.1:
For character types, all bits of
the object representation participate in the value representation
Ioannis said:Is it guaranteed that char, unsigned char, signed char have no padding bits?
Andrey said:Yes. Also, it is guaranteed that any combination of value forming bits
in unsigned character type is a valid combination. There's no such
guarantee for signed character type.
Ioannis said:I suppose it is guaranteed for plain char too.
Andrey said:Er.... Plain 'char' gets the same guarantees as the signed/unsigned char
type it shares its representation with.
This is actually why I used term 'character type' instead of 'char type'
in my previous message. "Unsigned character type" refers to both
'unsigned char' and 'char' on a platform where 'char' is unsigned. Same
for signed.
Ioannis said:I think there is a difference between C95 and C++03 on these. In both
languages it is guaranteed that any POD type can be treated as a
sequence of unsigned chars. I do not remember which language also
permits to be treated as a sequence of plain chars and/or-not signed chars.
In C (99, what the fark is 95?)
Ron said:char, unsigned char, signed char. None can have padding bits in C++.
PODS can be copied to arrays of "char" or "unsigned char". Signed
char behavior isn't specified.
In C (99, what the fark is 95?), you are right. It only makes
guarantees for unsigned char.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.