[llvm-bugs] [Bug 48787] New: Wrong size of arrays with over-aligned elements

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 18 04:22:48 PST 2021


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

            Bug ID: 48787
           Summary: Wrong size of arrays with over-aligned elements
           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

__declspec(align(8)) typedef int Int[3];

struct Y {
    Int y[3];
    int i;
};

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

msvc returns 40, clang returns 48 for the x86_64-pc-windows-msvc target.
Presumably because [1] rounds up the size to the alignment.

[1]
https://github.com/llvm/llvm-project/blob/689aaba7acf5778bfe96bfd7bc4f1f3ceed20dc8/clang/lib/AST/ASTContext.cpp#L1926-L1928

-- 
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/20210118/77e59e1f/attachment.html>


More information about the llvm-bugs mailing list