[llvm-bugs] [Bug 48875] New: Wrong size of struct with overaligned bitfield

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 25 11:30:28 PST 2021


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

            Bug ID: 48875
           Summary: Wrong size of struct with overaligned bitfield
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ju.orth at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Consider

struct Y {
        __declspec(align(128)) int i:1;
};

struct Z {
        char c;
        struct Y y;
};

int f(void) {
    return _Alignof(struct Y);
}

int g(void) {
    return sizeof(struct Z);
}

int h(void) {
    return &((struct Z *)0)->y;   // offsetof(struct Z, y)
}

MSVC returns

128
16
8

clang returns

128
256
128

on the aarch64-pc-windows-msvc target.

Apparently, on ARM targets, bitfields in structs increase the alignment of the
struct to at most 8 bytes. Even though _Alignof incorrectly returns a higher
value.

-- 
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/20210125/a4ea5edd/attachment.html>


More information about the llvm-bugs mailing list