Undefined behaviour of struct without members
KenjiroLotus opened this issue · 1 comments
The tasks
- c/ldv-regression/rule57_ebda_blast.i
- c/ldv-regression/rule57_ebda_blast_2.i
- c/ldv-regression/rule57_ebda_blast.c_1.i
contain a struct without members. After the C standard this leads to an undefined behaviour.
(C17, 6.7.2.1 Structure and union specifiers p8) "If the struct-declaration-list does not contain any named members, either directly or via an anonymous structure or anonymous union, the behavior is undefined."
However, this is allowed through a GNU C extension:
GCC permits a C structure to have no members:
struct empty {};
The structure has size zero
https://gcc.gnu.org/onlinedocs/gcc/Empty-Structures.html
The question is now wether this should be handled as an undefined behaviour or as a struct with size zero as specified in the GNU C extension.
The C programs in this repo are in general GNU C programs as mentioned in the readme. So it should be handled as struct with size 0.