C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

layout-compatible types and value representations

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Michael Norrish
Guest





PostPosted: Wed Apr 05, 2006 4:06 pm    Post subject: layout-compatible types and value representations Reply with quote



Does the standard allow

int *

and

unsigned *

to have different value representations and alignment requirements?
The language in the last sentence of 3.9.2 para 3 only requires
identical representations and alignments where the types pointed at
are "layout compatible".

It seems that the only places were layout compatibility allows any
deviation from exact identity is between enumerated types. Meaning
that int and unsigned int are not layout compatible.

----------

I'm also curious about the line in 3.9.1 para 3 which says that "the
value representation of each corresponding signed/unsigned type shall
be the same". I can understand what this might mean for the
non-negative values of the two types, but what might it mean for the
correspondence between values that are negative in the signed type and
positive in the unsigned one?

Thanks,
Michael.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to top
Tom Widmer
Guest





PostPosted: Tue Apr 11, 2006 4:06 pm    Post subject: Re: layout-compatible types and value representations Reply with quote



Michael Norrish wrote:
Quote:
Does the standard allow

int *

and

unsigned *

to have different value representations and alignment requirements?
The language in the last sentence of 3.9.2 para 3 only requires
identical representations and alignments where the types pointed at
are "layout compatible".

It seems that the only places were layout compatibility allows any
deviation from exact identity is between enumerated types. Meaning
that int and unsigned int are not layout compatible.

Agreed.

Quote:
----------

I'm also curious about the line in 3.9.1 para 3 which says that "the
value representation of each corresponding signed/unsigned type shall
be the same". I can understand what this might mean for the
non-negative values of the two types, but what might it mean for the
correspondence between values that are negative in the signed type and
positive in the unsigned one?

"The value representation of an object is the set of bits
that hold the value of type T."

So, the set of bits used to hold the value for the signed/unsigned types
will be the same (e.g. if the least significant bit is not used by the
unsigned type on some weird architecture, it shall not be used by the
signed one either).

Tom

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.