Repository navigation
Empty [[no_unique_address]] field can share the address of a same-typed subobject of a base class #543
gwllx
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.
Issue Summary
IA-64 class layout can place an empty
[[no_unique_address]]field so that it shares an address with an empty subobject of the same type in the tail padding of a base class.Reproducing Source Code
https://godbolt.org/z/f4d46W9Y3
Note: this issue is present for all types that are non-POD for layout purposes. EDG 6.9 (EDGcpfe/28918) extended this to any use of
[[no_unqiue_address]]in GNU mode, which brought the issue to my attention via the internal Axivion tests (similar to the above reproducer). Forcing a class to be non-POD in older versions also shows the same behaviour (note the addition of a user-provided ctor forB): https://godbolt.org/z/vqd5xWhGdCommand-line Options
cpfe --c++20 --g++
Type of Issue
[Front End] This code SHOULD compile with these options.
Additional Details
subobject_conflictreturnsfalsefor any offset beyondlob->curr_extend. For a base class,curr_extentcovers only the base size without tail padding. Empty subobjects of the base's[[no_unique_address]]members can lie in that tail padding, andsubobject_conflictnever checks them. When a derived class reuses the tail padding, its empty field can therefore get the same address as an empty subobject of the same type in the base.Reproducing (Standard) Configuration(s)
linux-gcc-release
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