------- Comment #3 from joseph at codesourcery dot com  2006-04-18 11:22 -------
Subject: Re:  hex and oct constants are converted to
 wrong type

On Tue, 18 Apr 2006, rguenth at gcc dot gnu dot org wrote:

> 6.10.1/3
> 
> The resulting tokens
> compose the controlling constant expression which is evaluated according to 
> the
> rules of
> 6.6, except that all signed integer types and all unsigned integer types act 
> as
> if they have
> the same representation as, respectively, the types intmax_t and uintmax_t
> defined
> in the header <stdint.h>.

I recommend quoting the current standard as amended by TC2, which makes 
this specific case even clearer in response to DR#265:

  The resulting tokens compose the controlling constant expression which 
  is evaluated according to the rules of 6.6. For the purposes of this 
  token conversion and evaluation, all signed integer types and all 
  unsigned integer types act as if they have the same representation as, 
  respectively, the types intmax_t and uintmax_t defined in the header 
  <stdint.h>.142)

  142) Thus, on an implementation where INT_MAX is 0x7FFF and UINT_MAX is 
  0xFFFF, the constant 0x8000 is signed and positive within a #if 
  expression even though it would be unsigned in translation phase 7.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27195

Reply via email to