|
From: | grischka |
Subject: | Re: [Tinycc-devel] [BUG] assertion failure when compiling initialization of array of structs on x86_64 |
Date: | Thu, 26 May 2016 14:07:40 +0200 |
User-agent: | Thunderbird 2.0.0.23 (Windows/20090812) |
Michael Matz wrote: ---
So, for this code: struct S { int i;} void f(struct S *s) { struct S y[1] = { *x }; } void g(struct S *s) { struct S y[1] = { { x->i } }; }TCC needs to differ between both cases and when parsing the LHS needs to dive into the type struct S for function g() but not for function f(), i.e. it needs to do that based on the form of the RHS.
I can't help, but such subtle complexity feels more like gcc than like C in general. The "normal" rule is that if nested braces are omitted then each member of the sub-struct (or sub-array) is assigned one by one from the remaining flat list. Which is what tcc does, in the f() case with the result of: test.c:13: error: cannot cast 'struct S' to 'int' As well as MS's cl for instance: test.c(13) : error C2440: 'initializing' : cannot convert from 'S' to 'int'
At that point I got distracted then :)
Me too now ... ;)
[Prev in Thread] | Current Thread | [Next in Thread] |