grischka
1ed20a01c9
bitfields: promote to signed int
...
For integer promotion with for example arithmetics or
expr_cond (x ? y : z), integral types need to be promoted
to signed if they fit.
According to latest standards, this also applies to bit-field
types taking into account their specific width.
In tcc, VT_BITFIELD set means width < original type width
Field-widths between 33 and 63 are promoted to signed long long
accordingly.
struct { unsigned long long ullb:35; } s = { 1 };
#define X (s.ullb - 2)
int main (void)
{
long long Y = X;
printf("%d %016llx %016llx\n", X < 0, -X, -Y);
return 0;
}
Results:
GCC 4.7 : 0 0000000000000001 FFFFFFF800000001
MSVC : 1 0000000000000001 0000000000000001
TCC : 1 0000000000000001 0000000000000001
Also, gcc would promote long long bitfields of size < 32
to int as well. Example:
struct { unsigned long long x:20; } t = { 123 };
/* with gcc: */ printf("%d %d\n", t.x, 456);
/* with tcc: */ printf("%lld %d\n", t.x, 456);
2017-05-09 18:36:24 +02:00
..
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2014-01-06 19:56:26 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2015-01-05 18:23:32 +03:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2015-11-22 00:00:36 +00:00
2015-11-22 00:00:36 +00:00
2016-10-12 06:18:38 +02:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2014-04-12 13:37:37 -04:00
2013-02-05 13:22:36 +01:00
2014-04-07 11:20:45 +02:00
2014-04-07 11:20:45 +02:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2016-01-11 07:51:58 +00:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2016-12-18 05:20:14 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 13:22:36 +01:00
2015-03-03 16:32:25 +03:00
2014-04-12 14:04:10 -04:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 14:27:38 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2013-02-05 13:22:36 +01:00
2014-03-25 20:54:19 +08:00
2014-03-25 20:54:19 +08:00
2014-03-25 20:54:19 +08:00
2014-03-25 20:54:19 +08:00
2014-03-30 12:56:55 +08:00
2014-03-30 12:56:55 +08:00
2014-03-30 12:56:55 +08:00
2014-03-30 12:56:55 +08:00
2014-03-30 12:56:55 +08:00
2014-03-30 12:56:55 +08:00
2014-03-30 12:56:55 +08:00
2016-03-24 15:44:01 +01:00
2014-03-30 12:56:55 +08:00
2014-03-30 12:56:55 +08:00
2014-03-31 22:59:10 +08:00
2014-03-31 22:59:10 +08:00
2015-03-03 16:32:25 +03:00
2014-04-07 23:30:57 +08:00
2014-04-12 16:11:42 +08:00
2014-04-12 16:11:42 +08:00
2014-12-15 16:32:08 +08:00
2014-12-15 16:32:08 +08:00
2015-01-18 22:00:10 +01:00
2015-01-18 22:00:10 +01:00
2015-05-09 14:29:39 +02:00
2015-05-09 14:29:39 +02:00
2015-03-07 17:42:08 +00:00
2015-03-07 17:42:08 +00:00
2015-03-10 23:27:14 +08:00
2015-03-10 23:27:14 +08:00
2015-03-23 08:27:16 +03:00
2015-03-23 08:27:16 +03:00
2015-04-20 12:03:45 +01:00
2015-04-20 12:03:45 +01:00
2015-04-25 15:03:50 +03:00
2015-04-25 15:03:50 +03:00
2015-11-21 23:58:58 +00:00
2015-11-21 23:58:58 +00:00
2015-11-13 21:49:29 +00:00
2015-04-28 09:23:29 +00:00
2016-03-11 22:35:44 +01:00
2016-03-11 22:35:44 +01:00
2017-05-02 03:07:36 +02:00
2016-03-24 15:44:01 +01:00
2016-04-06 14:32:52 +03:00
2016-04-06 14:32:52 +03:00
2016-04-05 13:05:09 +03:00
2016-04-05 13:05:09 +03:00
2017-02-13 19:03:29 +01:00
2017-02-13 19:03:29 +01:00
2017-02-13 19:03:29 +01:00
2017-02-13 19:03:29 +01:00
2017-02-13 19:03:29 +01:00
2017-02-13 19:03:29 +01:00
2016-12-15 17:47:12 +01:00
2016-12-15 17:47:12 +01:00
2016-12-20 04:58:34 +01:00
2016-12-20 04:58:34 +01:00
2017-02-13 19:03:29 +01:00
2017-02-13 19:03:29 +01:00
2017-05-06 05:28:13 +02:00
2017-05-06 05:28:13 +02:00
2017-02-13 19:03:29 +01:00
2017-02-13 19:03:29 +01:00
2017-05-05 23:16:43 +02:00
2017-05-05 23:16:43 +02:00
2017-05-09 18:36:24 +02:00
2017-05-09 18:36:24 +02:00
2013-02-05 13:22:36 +01:00
2017-04-25 21:01:54 +02:00