 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Michael Norrish Guest
|
Posted: Wed Apr 05, 2006 4:06 pm Post subject: layout-compatible types and value representations |
|
|
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
|
Posted: Tue Apr 11, 2006 4:06 pm Post subject: Re: layout-compatible types and value representations |
|
|
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 |
|
 |
|
|
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
|
|