Open ch3root opened 8 years ago
Structs with flexible array members are permitted in unions. Probably tis-interpreter rejects it for same reason -- considering such a struct an incomplete type.
Source code:
int main()
{
struct s {
int i;
int a[];
};
union u {
struct s s;
};
}
tis-interpreter (21f4c7a763b4601d723ea5749185c97115c9c98a) output:
test.c:8:[kernel] user error: field s is declared with incomplete type struct s
[kernel] user error: stopping on file "test.c" that has errors. Add '-kernel-msg-key pp'
for preprocessing command.
[kernel] Frama-C aborted: invalid user input.
gcc (GCC) 7.0.0 20160627 (experimental):
$ gcc -std=c11 -pedantic -Wall -Wextra -O3 -fsanitize=undefined test.c && ./a.out
clang version 3.9.0 (trunk 271312):
$ clang -std=c11 -Weverything -O3 -fsanitize=undefined test.c && ./a.out
Source code:
tis-interpreter (21f4c7a763b4601d723ea5749185c97115c9c98a) output:
The error is right but the message is wrong. struct s1 is not an incomplete type (and tis-interpreter, for example, doesn't complain about applying sizeof to it). Flexible array members are a special case.
gcc (GCC) 7.0.0 20160627 (experimental):
clang version 3.9.0 (trunk 271312):