[llvm-bugs] [Bug 51839] New: GCC and Clang disagree about packed record layout with non-POD fields
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 13 12:50:30 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51839
Bug ID: 51839
Summary: GCC and Clang disagree about packed record layout with
non-POD fields
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: rnk at google.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Consider:
https://gcc.godbolt.org/z/P4EKvYfr5
struct NonPod {
NonPod(); // matters
long long i64;
};
struct __attribute__ ((packed)) Packed {
char c;
NonPod a;
};
int theSize = sizeof(Packed);
GCC gives a size of 16, while clang gives a size of 9.
GCC also produces this warning:
warning: ignoring packed attribute because of unpacked non-POD field 'NonPod
Packed::a'
7 | NonPod a;
| ^
At this point, changing Clang's behavior would probably be a major ABI break.
Presumably this is a no-go for distributors unconcerned with GCC compatibility.
Therefore, it seems we need a LangOpt or something to control this behavior.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210913/9841cab3/attachment.html>
More information about the llvm-bugs
mailing list