Topic: layout-compatible types and value representations


Author: tom_usenet@hotmail.com (Tom Widmer)
Date: Tue, 11 Apr 2006 15:41:03 GMT
Raw View
Michael Norrish wrote:
> 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.

>                               ----------
>
> 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                      ]





Author: Michael.Norrish@nicta.com.au (Michael Norrish)
Date: Wed, 5 Apr 2006 15:32:36 GMT
Raw View
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                      ]