[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Ready for Release 0.9.27

From: grischka
Subject: Re: [Tinycc-devel] Ready for Release 0.9.27
Date: Thu, 09 Feb 2017 18:40:13 +0100
User-agent: Thunderbird (Windows/20090812)

Vincent Lefevre wrote:

The C standard says: Boolean, characters, and integers


  If an int can represent all values of the original type (as
  restricted by the width, for a bit-field), the value is converted
  to an int; otherwise, it is converted to an unsigned int. These are
  called the integer promotions.58) All other types are unchanged by
  the integer promotions.

In my example of my Debian bug report:

  struct { unsigned int a:3; } s = { 1 };

  s.a - 2

The original type (a 3-bit unsigned bit-field) contains the values
from 0 to 7. An int can represent all of them. Thus s.a is converted
to an int, and s.a - 2 gives -1 (as an int).

But according to the test, tcc seems to regard s.a - 2 as
(unsigned int) (-1), i.e. UINT_MAX. However, tcc behaves correctly
on ((unsigned char) 1 - 2), giving -1.

Note that GCC 6.3.0, ICC 15.0.0 and Clang 3.9.1 are correct on this

But note that MSVC still behaves like tcc, and that such behavior
can be seen compliant to the standard too, at least before the rather
recent addition of the

   ... (as restricted by the width, for a bit-field) ...

phrase, with the result that now basically every possible ':X' field-width
is supposed to define its own integral C type.

--- grischka

reply via email to

[Prev in Thread] Current Thread [Next in Thread]