[llvm-bugs] [Bug 37275] New: packed attribute should not apply to base classes

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 27 13:02:21 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37275

            Bug ID: 37275
           Summary: packed attribute should not apply to base classes
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Per the GCC documentation, the 'packed' attribute on a class is applied to all
non-static data members of that class ("Specifying the packed attribute for
struct and union types is equivalent to specifying the packed attribute on each
of the structure or union members."). It should *not* be applied to base
classes. Testcase:

struct A { int n; };
static_assert(alignof(A) == alignof(int));

struct [[gnu::packed]] B : A {};
static_assert(alignof(B) == alignof(int));

This test passes with GCC, but fails with Clang because we incorrectly give B
1-byte alignment.

-- 
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/20180427/0ed9fd66/attachment.html>


More information about the llvm-bugs mailing list