-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
struct s1
{
int __attribute__ ((aligned (8))) a;
};
struct
{
char c;
struct s1 m;
} v;
int
main (void)
{
if ((int)&v.m & 7)
abort ();
exit (0);
}
compile with only one option:-fpack-struct=4
gcc could pass this testcase, but clang could not.
https://godbolt.org/z/h5T5rdYWb
The code can be simplified as follows:
struct s1
{
int __attribute__ ((aligned (8))) a;
}s;
https://godbolt.org/z/EbGsEz6eP

if compile without -fpack-struct=4, the alignment of struct is 8, as same as attribue. But if compile with -fpack-struct=4, the alignment of struct is 4. Why fpack-struct=4 has a higher priority than attribute? I think attribute should has a higher priority than Compilation options
Metadata
Metadata
Assignees
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!