Padding bits and char, unsigned char, signed char

I

Ioannis Vranos

Under C++03:

Is it guaranteed that char, unsigned char, signed char have no padding bits?
 
V

Victor Bazarov

Ioannis said:
Under C++03:

Is it guaranteed that char, unsigned char, signed char have no
padding bits?

I can find no such guaranteed in the document (you still haven't
got your own copy?)

V
 
R

Ron Natalie

Ioannis said:
Under C++03:

Is it guaranteed that char, unsigned char, signed char have no padding bits?

Yes, the first paragraph of 3.9.1:

For character types, all bits of
the object representation participate in the value representation
 
R

Ron Natalie

Victor said:
I can find no such guaranteed in the document (you still haven't
got your own copy?)

V
3.9.1

For character types, all bits of
the object representation participate in the value representation
 
I

Ioannis Vranos

Ron said:
Yes, the first paragraph of 3.9.1:

For character types, all bits of
the object representation participate in the value representation


OK, thanks. The plural form "types" obviously contains char, signed char
and unsigned char.
 
A

Andrey Tarasevich

Ioannis said:
Is it guaranteed that char, unsigned char, signed char have no padding bits?

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.
 
I

Ioannis Vranos

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.


I suppose it is guaranteed for plain char too.
 
A

Andrey Tarasevich

Ioannis said:
I suppose it is guaranteed for plain char too.

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.
 
I

Ioannis Vranos

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.


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.
 
R

Ron Natalie

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.

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.
 
I

Ioannis Vranos

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.


OK, thanks for the clarification. C95 is ISO/IEC 9899:1995 - Amendment 1.

Basically it is C90+ 3 standard header files, <wchar.h>, <wctype.h>,
<iso646.h>.


C95 is really the C "subset" of C++98, not C90.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top