c2compiler: sub-struct initialization fails
The analysis pass of the following code fails:
type T struct {
i32 i;
union {
u32 u;
void* p;
}
}
T t1 = { 10, .u=20 } // error: field designator 'u' does not refer to any field in type '(struct)T'
Mixing designated initializers with non-designated ones seems to be allowed in C for substructs. The Analyzer also needs to search sub-structs/unions and keep track of what’s initialized as well
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (7 by maintainers)
Yes, I’ve already added some comments in the code as well. It requires some refactoring of struct analysis. I’m on it, but it is a bit nasty indeed.
I’ve added 2 skipped tests: test/Init/init_sub_union_field_designator.c2 and test/Init/init_union_non_designator.c2