https://bugs.llvm.org/show_bug.cgi?id=48776
Bug ID: 48776
Summary: Wrong alignment of __declspec(align)ed structs
Product: clang
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Consider
__declspec(align(2)) struct X {
int a;
};
#pragma pack(1)
struct Y {
struct X x;
};
int f(void) {
return _Alignof(struct Y);
}
msvc returns 2, clang returns 4 on the x86_64-pc-windows-msvc target.
Presumably because of [1]. If a struct has _any_ alignment attribute, the
branch is taken and the overall alignment of the struct is considered required.
I do not know the actual behavior of msvc, but I figure that the fix is to
exclude RecordType fields from this branch because their required alignment is
already handled in [2]. This bug seems to have been introduced in [3].
[1]
https://github.com/llvm-mirror/clang/blob/aa231e4be75ac4759c236b755c57876f76e3cf05/lib/AST/RecordLayoutBuilder.cpp#L2447-L2449
[2]
https://github.com/llvm-mirror/clang/blob/aa231e4be75ac4759c236b755c57876f76e3cf05/lib/AST/RecordLayoutBuilder.cpp#L2456-L2462
[3] https://reviews.llvm.org/D4714
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs