Il 17/07/20 19:55, Thiago Macieira ha scritto:
moc generates:Type Klass::_qt_property_api_propertyName::value() const { const size_t propertyMemberOffset = reinterpret_cast<size_t>(&(static_cast<Klass *>(nullptr)->propertyName)); const auto *thisPtr = reinterpret_cast<const Klass *>( reinterpret_cast<const char *>(this) - propertyMemberOffset); return thisPtr->d_func()->property.value(); } The first two lines of this function are UB. It MUST be fixed.
The first line smells like offsetof, which we might be lucky enough to use -- in C++17 it became conditionally supported whether it works on non-standard layout classes (QObject), and apparently GCC/Clang/MSVC all support it.
The second line smells 99.99% unfixable UB. Would using ASM be an acceptable "fix"?
In the process, please also fix this code:
auto prop = object->propertyName;
return prop.value();
How? Just like QStringBuilder, there's no way to block a `const auto &`, is there?
Thanks, -- Giuseppe D'Angelo | [email protected] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
