[llvm-bugs] [Bug 48777] New: Wrong alignment of nested __declspec(align)s

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 16 17:32:26 PST 2021


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

            Bug ID: 48777
           Summary: Wrong alignment of nested __declspec(align)s
           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 I1;

__declspec(align(1)) typedef I1 I2;

struct X {
        I2 i;
};

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

msvc returns 8, clang returns 4 on the target x86_64-pc-windows-msvc. The
problem is that [1] ignores all typedefs and [2] only considers the outermost
typedef.

[1]
https://github.com/llvm/llvm-project/blob/a048ce13e32daa255d26533c00da8abd0b67e819/clang/lib/AST/RecordLayoutBuilder.cpp#L2586-L2587

[2]
https://github.com/llvm/llvm-project/blob/a048ce13e32daa255d26533c00da8abd0b67e819/clang/lib/AST/RecordLayoutBuilder.cpp#L2593-L2595

-- 
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/20210117/1e98f298/attachment.html>


More information about the llvm-bugs mailing list