If it helps maintainers, changing the code to
struct A a[] = { {1}, {2}, }; Compiles and works. As does: struct A b[2] = { (struct A){1}, (struct A){2}, }; Maybe the cast adds extra alignment From: Tyge Løvset [mailto:tylov...@gmail.com] Sent: Sunday, February 20, 2022 16:23 To: jull...@eligis.com; tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] initializer overflow with arrays on implicit size I have reported this before and tried a bit to debug without success. Very annoying. Only useful info I can give is that is does not happen on GCC compiled on windows, but everywhere else. Might suggest uninitialized memory. lør. 12. feb. 2022, 07:20 skrev Christian Jullien <eli...@orange.fr>: Important precision, I reproduce this issue with mob including on RPi arm32; $ tcc foo.c foo.c:8: error: internal compiler error tccgen.c:7728: in init_assert(): initializer overflow -----Original Message----- From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis <mailto:tinycc-devel-bounces%2Beligis> =orange...@nongnu.org] On Behalf Of Arthur Williams via Tinycc-devel Sent: Saturday, February 12, 2022 03:33 To: tinycc-devel@nongnu.org Cc: Arthur Williams Subject: [Tinycc-devel] initializer overflow with arrays on implicit size Greetings, Found a strange error when trying to build a program with tcc. The error is ``` test.c:8: error: internal compiler error tccgen.c:7728: in init_assert(): initializer overflow ``` And here is a minimal example of how to repro it. ``` #include <stdio.h> struct A { char a; char b; }; int main() { struct A a[] = { (struct A){1}, (struct A){2}, }; printf("%d %d\n", a[0].a, a[0].b); printf("%d %d\n", a[1].a, a[1].b); return 0; } ``` (printing isn't need to repro the problem) Took a glance at the code that was generating the error message: `init_assert`. The commit message for that function seems to imply that is was temporary and removing this function avoid the error and allows the code to compile. Tests pass and the output is also as expected. Is there a reason to keep this function around? Playing around with the function removed and while the code compiles find, running with `tcc -run` segfaults. So I imagine the real fix is a bit less trivial that what I had thought. Arthur _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel