Issue
I found out that structures without any named members (and without any members in particular, as I understood) invoke UB in C. Only GNU GCC supports such structures as an extension. I've tried to create a piece of code which will behave differently when compiled using GCC vs. Clang but with no success. I'm wondering if there is a C program that if you compile it via Clang, it will work differently than if it was compiled using GCC. The opposite option, in a nutshell, is that Clang also supports empty structures but this is not mentioned in documentation.
Solution
Literally the only thing I could find in clang's documentation is some info about a warning -Wgnu-empty-struct
, which will be activated in -pedantic
mode. So the compiler clearly supports GNU empty structs.
As for where to find the clang documentation regarding how empty structs should be used, what they are good for and under which language standards they are valid, I have no idea.
Answered By - Lundin Answer Checked By - David Goodson (WPSolving Volunteer)