tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] initializer overflow with arrays on implicit size


From: Arthur Williams
Subject: [Tinycc-devel] initializer overflow with arrays on implicit size
Date: Fri, 11 Feb 2022 18:32:47 -0800

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]