It does work "in practice", but from the answer I got on SO, it's still technically UB. If anyone wants to add another, more positive answer sourced from the standard though it'd be very welcome :)
https://stackoverflow.com/questions/57823192/does-casting-an-empty-base-class-optimized-object-to-another-type-break-strict-a/57823574 All the best, Jean-Michaël On Fri, Jul 17, 2020 at 9:26 AM Lars Knoll <lars.kn...@qt.io> wrote: > > > > On 16 Jul 2020, at 23:35, Thiago Macieira <thiago.macie...@intel.com> > wrote: > > > > On Thursday, 16 July 2020 13:16:41 PDT Giuseppe D'Angelo via > Development > > wrote: > >> Il 16/07/20 12:43, Volker Hilsheimer ha scritto: > >>> For pre-C++20 (where it’s possible to have zero-size structs), and for > >>> compilers that don’t respect the [[no_unqiue_address]] attribute, all > >>> these struct-instances are put into a union. In that case, a class > using > >>> QProperty will be larger (by the same amount no matter the number of > >>> properties) than the same class in Qt 5. With C+++ 20 and compilers > that > >>> do respect [[no_unique_address]], the size and layout of these classes > >>> will be the same. > >> I'm not fully understanding this last part -- does changing compiler > >> break ABI, because the implementation of properties change (from an > >> union to [[no_unique_address]] members)? > > > > Yes. > > > > Already sent a -2 to the commit that added this support, because it > can't > > work. The commit will need to be reverted. > > Yes, it can and it does work. And it’s what we should be doing on > compilers that support [[no_unique_address]]. > > It does mean that a pure C++17 and a C++20 build aren’t binary compatible, > but I think we should pay that price. > > If I remember correctly, the only compiler that doesn’t yet support it is > MSVC. BC mainly matters on desktop Linux and those all support the feature, > so we can enable it from the get go. > > Cheers, > Lars > > > > -- > > Thiago Macieira - thiago.macieira (AT) intel.com > > Software Architect - Intel System Software Products > > > > > > > > _______________________________________________ > > Development mailing list > > Development@qt-project.org > > https://lists.qt-project.org/listinfo/development > _______________________________________________ > Development mailing list > Development@qt-project.org > https://lists.qt-project.org/listinfo/development >
_______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development