diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-07 13:30:31 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-07 18:47:48 +0000 |
commit | 277c23956cd4a298a57dad9e777259680a520730 (patch) | |
tree | 0e94a8c8178555d5246fcc56590454a7b3e2d955 /src/corelib/global/qlibraryinfo.cpp | |
parent | 32f1847e1e3f13dc64baf8e90e7ce0a360c71aba (diff) |
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>
Diffstat (limited to 'src/corelib/global/qlibraryinfo.cpp')
0 files changed, 0 insertions, 0 deletions