-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor initialization issue with unions #411
Comments
Just for completeness: C99 and C11 also state "...first named member of a union". |
Note: in C11 and C17, anonymous fields that have union or structure type are treated specially, they expose their subfields (transitively) as though they were fields of the outer object. This is not the case here, but you may want to look into this. |
For the record, a full analysis of this issue:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to C17 6.7.9.17 "When no designations are present, subobjects of the current object are initialized in order according to the type of the current object: [...] the first named member of a union."
Accordingly, gcc considers that the initializer initializes
c
to 730. In contrast, CompCert considers that it initializes the unnamed field to 730, which gets truncated to 218. So it seems CompCert's behavior is incorrect.I don't think this is something likely to show up in real code, except perhaps if the unnamed field is meant as some form of padding.
The text was updated successfully, but these errors were encountered: