aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/inlinecomponentutils_p.h
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2021-12-15 09:43:47 +0100
committerMarc Mutz <[email protected]>2021-12-16 20:03:31 +0000
commitcf60baa44f33377c8bd3bfd4273883ac5c129d54 (patch)
tree63470949f6032c0cc28d645416ee09857488866b /src/qml/inlinecomponentutils_p.h
parent2f45a9c2b9f3a136f6933b6faa8e223a634b28a6 (diff)
icutils::Node: GCC 11 -Werror=maybe-uninitialized w/-fsanitize=undefined
The quint32_le_bitfield class, like its underlying type, doesn't provide a user-defined constructor, so default-construction leaves the 'val' member uninitialized. When the user-defined assignment operator then tries to read from 'val', that is undefined behavior. Or would, if vector::resize() wouldn't value-initialize, which it is required to do. So, False Positive, but due to -Werror, we need to do something about it (value-initialize the largest union member before calling assignment). Says GCC 11 with -stc=c++20 -fsanitize=undefined -Werror: In member function ‘QSpecialIntegerBitfield<S, pos, width>& QSpecialIntegerBitfield<S, pos, width>::operator=(QSpecialIntegerBitfield<S, pos, width>::T) [with S = QLittleEndianStorageType<unsigned int>; int pos = 0; int width = 30]’, inlined from ‘icutils::Node::Node(std::vector<QV4::CompiledData::InlineComponent>::size_type)’ at qt5-build/qtbase/include/QtQml/6.3.0/QtQml/private/../../../../../../../qt5/qtdeclarative/src/qml/inlinecomponentutils_p.h:66:26, inlined from ‘constexpr void std::iota(_ForwardIterator, _ForwardIterator, _Tp) [with _ForwardIterator = __gnu_cxx::__normal_iterator<icutils::Node*, std::vector<icutils::Node> >; _Tp = int]’ at /d/gcc/11/include/c++/11.2.1/bits/stl_numeric.h:99:4, inlined from ‘void QV4::ExecutableCompilationUnit::finalizeCompositeType(QQmlEnginePrivate*, CompositeMetaTypeIds)’ at qt5/qtdeclarative/src/qml/jsruntime/qv4executablecompilationunit.cpp:444:14: qt5-build/qtbase/include/QtCore/6.3.0/QtCore/private/../../../../../../../qt5/qtbase/src/corelib/global/qendian_p.h:78:30: warning: ‘*(QSpecialIntegerBitfield<QLittleEndianStorageType<unsigned int>, 0, 30>*)((char*)&<unnamed> + offsetof(icutils::Node, icutils::Node::<unnamed>)).QSpecialIntegerBitfield<QLittleEndianStorageType<unsigned int>, 0, 30>::val’ may be used uninitialized [-Wmaybe-uninitialized] 78 | UT i = S::fromSpecial(val); | ~~~~~~~~~~~~~~^~~~~ In file included from /d/gcc/11/include/c++/11.2.1/numeric:62, from qt5/qtbase/src/corelib/tools/qhashfunctions.h:47, from qt5-build/qtbase/include/QtCore/qhashfunctions.h:1, from qt5/qtbase/src/corelib/tools/qlist.h:46, from qt5-build/qtbase/include/QtCore/qlist.h:1, from qt5/qtbase/src/corelib/kernel/qobject.h:49, from qt5-build/qtbase/include/QtCore/qobject.h:1, from qt5/qtbase/src/corelib/animation/qabstractanimation.h:43, from qt5-build/qtbase/include/QtCore/qabstractanimation.h:1, from qt5-build/qtbase/include/QtCore/QtCore:9, from qt5-build/qtdeclarative/src/qml/CMakeFiles/Qml.dir/cmake_pch.hxx:5, from <command-line>: /d/gcc/11/include/c++/11.2.1/bits/stl_numeric.h: In member function ‘void QV4::ExecutableCompilationUnit::finalizeCompositeType(QQmlEnginePrivate*, CompositeMetaTypeIds)’: /d/gcc/11/include/c++/11.2.1/bits/stl_numeric.h:99:20: note: ‘<anonymous>’ declared here 99 | *__first = __value; | ~~~~~~~~~^~~~~~~~~ Pick-to: 6.3 6.2 5.15 Change-Id: I8bbe32438489120bd005e115ea34cd816c898116 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src/qml/inlinecomponentutils_p.h')
-rw-r--r--src/qml/inlinecomponentutils_p.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/qml/inlinecomponentutils_p.h b/src/qml/inlinecomponentutils_p.h
index ae436d53b0..74805d6d7c 100644
--- a/src/qml/inlinecomponentutils_p.h
+++ b/src/qml/inlinecomponentutils_p.h
@@ -62,7 +62,9 @@ struct Node {
Node& operator=(Node &&) = default;
bool operator==(Node const &other) const {return index == other.index;}
- Node(std::vector<QV4::CompiledData::InlineComponent>::size_type s) {
+ Node(std::vector<QV4::CompiledData::InlineComponent>::size_type s)
+ : index{0}
+ {
index = quint32(s);
temporaryMark = 0;
permanentMark = 0;