diff options
| author | grischka <grischka> | 2017-05-09 18:36:24 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2017-05-09 18:36:24 +0200 |
| commit | 1ed20a01c962ea15b4f4486a9ec17160313e3314 (patch) | |
| tree | 70613b17b8ba864270301b887d9f9f0e12de6e94 /tests/tests2/84_hex-float.expect | |
| parent | d242706f3b739bcb00de1d970a01a319db6ad77d (diff) | |
| download | tinycc-1ed20a01c962ea15b4f4486a9ec17160313e3314.tar.gz tinycc-1ed20a01c962ea15b4f4486a9ec17160313e3314.tar.bz2 | |
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);
Diffstat (limited to 'tests/tests2/84_hex-float.expect')
0 files changed, 0 insertions, 0 deletions
