Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt to MSVC difference in behavior in initializing non-aggregates
Testcase: struct A { A() = default; constexpr A(int v) :i(v) {} int i; }; extern const A y[1] = {}; In our case, A = std::atomic<int> and y = shared_null. With GCC, ICC, and Clang that "y" variable is value-initialized at static initialization time, and no dynamic initialization code is generated. However, with MSVC, because A is not an aggregate, the default constructor isn't constexpr (it leaves A::i uninitialized) so "y" must be dynamically initialized. That leads to Static Initialization Order Fiasco. This seems to be a regression in the MSVC 2019 16.6 STL: microsoft/STL#661 The solution is simple: call the constexpr constructor. Code is different in 6.0 so sending separately from 5.x. Fixes: QTBUG-71548 Task-number: QTBUG-59721 Pick-to: 5.12 Change-Id: I3d4f433ff6e94fd390a9fffd161b4a7e8c1867b1 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
- Loading branch information