[llvm-bugs] [Bug 50014] New: Missing [[no_unique_address]] on Windows

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 17 11:15:09 PDT 2021


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

            Bug ID: 50014
           Summary: Missing [[no_unique_address]] on Windows
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rob.klein.ikink at student.nhlstenden.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 24764
  --> https://bugs.llvm.org/attachment.cgi?id=24764&action=edit
test.cpp: the source file that triggers the warning. log.txt: console output
from compiling test.cpp.

https://clang.llvm.org/cxx_status.html#cxx20 lists the [[no_unique_address]]
attribute as supported since Clang 9. However, the attribute does not seem to
currently be supported on Windows platforms.

Compiling the following source code on Windows with Clang 12.0.0 with
-std=c++20:

struct X {};

struct Y1 {
        [[no_unique_address]] X x;
        long long a;
};

struct Y2 {
        X x;
        long long a;
};

int main() {}

gives the following warning:

test.cpp:4:4: warning: unknown attribute 'no_unique_address' ignored
[-Wunknown-attributes]
        [[no_unique_address]] X x;
          ^~~~~~~~~~~~~~~~~
1 warning generated.

The size of objects from Y1 are also the same size as those from Y2, indicating
that an unique address is indeed still generated:

std::cout << sizeof(Y1) << ", " << sizeof(Y2);

prints "16, 16" compared to "8, 16" on Linux: https://godbolt.org/z/nfaf3KeP3

-- 
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/20210417/30c055f8/attachment-0001.html>


More information about the llvm-bugs mailing list