[Development] QProperty and library coding guide
lars.knoll at qt.io
Mon Jul 20 10:23:39 CEST 2020
> On 20 Jul 2020, at 07:24, Thiago Macieira <thiago.macieira at intel.com> wrote:
> On Sunday, 19 July 2020 14:42:24 PDT Giuseppe D'Angelo via Development wrote:
>> * change /*2*/ to use ASM. We know the ABI of the platforms we support
>> and we know how to calculate the correct pointer value, we just need to
>> stop C/C++ from reason about it and flagging it as possible UB. Yes,
>> it's a crude hack...
> ASM is not a solution. There's at least one major compiler (MSVC) that doesn't
> allow any assembler.
Sure it does, just not inline. So ASM can be a solution if required. For MSVC, we’d simply call the assembly out of line.
But I don’t see why we would need to do this now, if the code we have works fine on current compilers. It’s all non inline, so we could add those kind of workarounds only if they become a requirement for a certain compiler.
> But see Ville's email. I think the pointer arithmetic is actually fine. Would
> be fine too with uchar*.
What we’re doing is basically the reverse operation of:
T* o = ...;
U *m = &o->m;
We need to go from the pointer to m back to the pointer of the surrounding object. While one way it perfectly defined by C++, there is unfortunately no way to reverse the operation in the standard.
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel System Software Products
> Development mailing list
> Development at qt-project.org
More information about the Development