Hi,
On Sun, 22 Jun 2014, jiang wrote:
This is my patch (see Annex)
tcc result is correct
--> 254 / 30 / 126
That's not the correct result. If you think it is the probably because
you're confused by the semantics of assignments as rvalue.
I guess gcc & mvc repeated use of the register, so wrong
No, GCC and MSVC are correct.
struct {
unsigned a:9, b:5, c:7;
} _s, *s = &_s;
int n = 250;
s->a = s->b = s->c = n + 4;
To show that GCC is correct (and TCC wrong, and your patch still wrong)
rewrite the above into the explicit expansion according to associativity
of '=':
s->c = n + 4; // s->c == 254 & 127 == 126
s->b = s->c; // s->b == 126 & 31 == 30
s->a = s->b; // s->a == 30
In particular the value loaded into s->a comes from s->b, and hence is the
truncated value, which isn't changed anymore as 5 bits fits into 9 bits.
Ciao,
Michael.
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel