Repository navigation
Layout for [[no_unique_address]] members is not optimal under Cfront-like layout
#277
cpplearner
started this conversation in
Issue Triage - Compilation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
When a struct contains multiple
[[no_unique_address]]members of the same type, these members occupy storage, making the struct larger than needed, under Cfront-like layout.It appears that the byte offsets of empty members are computed before those of non-empty members, and thus the initial offset of the latter depends on the final offset of the former. That is, an empty member cannot share storage with a non-empty member other than the first byte of the first non-empty member.
Clang, GCC, and MSVC (with
[[msvc::no_unique_address]]) are able to produce the optimal layout for the repro below, as does EDG under Itanium ABI.This causes discrepancy between Visual Studio's EDG-based IntelliSense and MSVC compiler.
Reproducing Source Code
Command-line Options
cpfe --ms_c++20 test-no-unique-address.cpp
Type of Issue
[Front End] This code SHOULD compile with these options.
Additional Details
No response
Reproducing (Standard) Configuration(s)
windows-msvc-debug
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions