[Development] QProperty and library coding guide

Thiago Macieira thiago.macieira at intel.com
Wed Jul 22 01:13:52 CEST 2020


On Tuesday, 21 July 2020 13:51:11 PDT Ville Voutilainen wrote:
> See also all the memcpys that are done with types that are
> polymorphic, and the ones
> where we memcpy types that have user-provided copy operations. qtbase
> is UB left right
> and center, but it's certainly interesting that when a new thing in it
> might be clarified
> not to be UB after all, we perform all kinds of somersaults to avoid
> such dark corners.

I'm willing to accept _de jure_ UB today if there's a strong sentiment that 
this is an artifact of the way the standard is written, not an intentional 
carve-out like signed integer overflows are; preferably, with the committee on 
the record saying it wants to eventually fix this. A paper like P1839 being 
seriously considered counts as "being on the record" for me.

With this stated direction, we can rely that compilers do not and will not 
optimise this UB away and will instead interpret it either as IB or as 
completely defined.

Also required: that neither UBSan nor ASan produce errors when Qt or the user 
code is compiled with them. Using __attribute__ to silence them is acceptable.

The memcpys qualify under all of those conditions, with even explicit 
workarounds in the compilers. I don't see why you think qobject_cast has UB; 
did you mean qFindChildren?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering





More information about the Development mailing list