[llvm-bugs] [Bug 40809] New: Zero-width bit-field in an anonymous subobject
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 21 13:04:36 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40809
Bug ID: 40809
Summary: Zero-width bit-field in an anonymous subobject
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: aaron at aaronballman.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
I believe the following structure has the incorrect layout according to the C
standard:
struct S {
int i : 1;
union {
int : 0;
};
int j : 1;
};
int main(void) {
return sizeof(struct S) == sizeof(int);
}
main() should return 0, but in Clang it returns 1.
C17 6.7.2.1p13 makes it clear that the members of the anonymous union are
members of the enclosing struct, so the zero-width bit-field should introduce
an allocation boundary via p12.
FWIW, Clang matches GCC's behavior here, but not MSVC's behavior.
I believe this is an instance where the behavior in C and C++ have diverged,
because [class.union.anon]p1 (http://eel.is/c++draft/class.union.anon#1) says
that the anonymous union members are only members of the containing object for
purposes of name lookup.
--
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/20190221/447940bc/attachment.html>
More information about the llvm-bugs
mailing list