qt5base-lts/tests/auto/other/qobjectrace
Marc Mutz 277c23956c tst_qobjectrace: fix potential UB (something with pointers and new)
The current [basic.life] wording seems to cover the existing code, but
IIRC, older versions of [basic.life] were not so relaxed. In
particular, while not completely pertinent, the second placement new
is awfully similar to http://eel.is/c++draft/ptr.launder#example-1

Just make all of this SEP and use std::optional. That way, the code
gets simpler, too, plus we get rid of the last use of C++23-deprecated
std::aligned_storage.

The reset() before the 2nd emplace() isn't necessary, but, in a test,
it doesn't hurt, either, and keeps code readers from guessing whether
the first-emplaced object's dtor is actually properly run (it is).

Pick-to: 6.3 6.2
Fixes: QTBUG-99122
Change-Id: If31a46f8be3a74499f1176133029d097faf7dfe9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-07 18:47:48 +00:00
..
.gitignore Moved integrationtests/* into other/ 2011-11-30 09:30:22 +01:00
CMakeLists.txt Move QEMU emulation detector to QTest 2021-02-13 10:02:51 +02:00
tst_qobjectrace.cpp tst_qobjectrace: fix potential UB (something with pointers and new) 2022-05-07 18:47:48 +00:00