tcc does not follow the integer promotion rules on bit-fields.
For instance, consider the following code:

#include <stdio.h>

union ui
{
  struct
    {
      unsigned int manl:32;
      unsigned int manh:20;
      unsigned int exp:11;
      unsigned int sig:1;
    } s;
  double d;
};

union ul
{
  struct
    {
      unsigned long manl:32;
      unsigned long manh:20;
      unsigned long exp:11;
      unsigned long sig:1;
    } s;
  double d;
};

int main (void)
{
  union ui xi;
  union ul xl;

  xi.d = 0.5;
  xl.d = 0.5;

  printf ("%d %lx\n", xi.s.exp - 1023 < 0, (unsigned long) (xi.s.exp - 1023));
  printf ("%d %lx\n", xl.s.exp - 1023 < 0, (unsigned long) (xl.s.exp - 1023));
  return 0;
}

With GCC and ICC, I get:

1 ffffffffffffffff
1 ffffffffffffffff

But with tcc, I get:

0 ffffffff
0 ffffffffffffffff

Since all the values of xi.s.exp and xl.s.exp are representable
in an int, the bit-field type should be converted to int for the
subtraction, so that the < 0 should be true in both cases.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to