Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.10
-
None
-
eb1342a3c (dev), db36fea29 (6.9), 1a580ca2a (dev)
Description
I was getting a weird compile error:
FAILED: qtdeclarative/src/qmldom/CMakeFiles/QmlDomPrivate.dir/qqmldomreformatter.cpp.o /opt/homebrew/bin/ccache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DGL_SILENCE_DEPRECATION -DQMLDOM_LIBRARY -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_QMLDOM_LIB -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_LEAN_HEADERS=1 -DQT_MOC_COMPAT -DQT_NETWORK_LIB -DQT_NO_AS_CONST=1 -DQT_NO_CAST_TO_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_FOREACH=1 -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QASCONST -DQT_NO_QEXCHANGE -DQT_NO_QSNPRINTF -DQT_NO_QSNPRINTF=1 -DQT_NO_STD_FORMAT_SUPPORT -DQT_QMLCOMPILER_LIB -DQT_QMLINTEGRATION_LIB -DQT_QMLTOOLINGSETTINGS_LIB -DQT_QML_LIB -DQT_STRICT_QLIST_ITERATORS -DQT_USE_QSTRINGBUILDER -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -I/Users/sami/projects/qt-dom-build/qtdeclarative/src/qmldom/QmlDomPrivate_autogen/include -I/Users/sami/projects/qt-dom-build/qtbase/include -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlDom -I/Users/sami/projects/qt-dom/qtdeclarative/src/qmldom -I/Users/sami/projects/qt-dom-build/qtdeclarative/src/qmldom -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlDom/6.10.0 -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlDom/6.10.0/QtQmlDom -I/Users/sami/projects/qt-dom-build/qtdeclarative/src/qml -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQml/6.10.0 -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQml/6.10.0/QtQml -I/Users/sami/projects/qt-dom-build/qtbase/src/corelib -I/Users/sami/projects/qt-dom-build/qtbase/include/QtCore/6.10.0 -I/Users/sami/projects/qt-dom-build/qtbase/include/QtCore/6.10.0/QtCore -I/Users/sami/projects/qt-dom-build/qtbase/include/QtCore -I/Users/sami/projects/qt-dom-build/qtbase/lib/QtCore.framework/Headers -I/Users/sami/projects/qt-dom-build/qtbase/mkspecs/macx-clang -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQml -I/Users/sami/projects/qt-dom-build/qtbase/lib/QtQml.framework/Headers -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlIntegration -I/Users/sami/projects/qt-dom/qtdeclarative/src/qmlintegration -I/Users/sami/projects/qt-dom-build/qtdeclarative/src/qmlintegration -I/Users/sami/projects/qt-dom-build/qtbase/include/QtNetwork -I/Users/sami/projects/qt-dom-build/qtbase/lib/QtNetwork.framework/Headers -I/Users/sami/projects/qt-dom-build/qtdeclarative/src/qmlcompiler -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlCompiler/6.10.0 -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlCompiler/6.10.0/QtQmlCompiler -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlToolingSettings -I/Users/sami/projects/qt-dom-build/qtdeclarative/src/qmltoolingsettings -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlToolingSettings/6.10.0 -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlToolingSettings/6.10.0/QtQmlToolingSettings -I/Users/sami/projects/qt-dom-build/qtbase/include/QtQmlCompiler -I/Users/sami/projects/qt-dom-build/qtbase/lib/QtQmlCompiler.framework/Headers -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -std=gnu++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -mmacosx-version-min=12 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -F/Users/sami/projects/qt-dom-build/qtbase/lib -Wall -Wextra -fapplication-extension -ftrivial-auto-var-init=pattern -fstack-protector-strong -fno-exceptions -MD -MT qtdeclarative/src/qmldom/CMakeFiles/QmlDomPrivate.dir/qqmldomreformatter.cpp.o -MF qtdeclarative/src/qmldom/CMakeFiles/QmlDomPrivate.dir/qqmldomreformatter.cpp.o.d -o qtdeclarative/src/qmldom/CMakeFiles/QmlDomPrivate.dir/qqmldomreformatter.cpp.o -c /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomreformatter.cpp In file included from /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomreformatter.cpp:4: In file included from /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomreformatter_p.h:20: In file included from /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomoutwriter_p.h:20: In file included from /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomfilelocations_p.h:19: In file included from /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomitem_p.h:20: In file included from /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldom_utils_p.h:20: In file included from /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomconstants_p.h:20: In file included from /Users/sami/projects/qt-dom-build/qtbase/include/QtCore/QObject:1: In file included from /Users/sami/projects/qt-dom-build/qtbase/include/QtCore/qobject.h:1: In file included from /Users/sami/projects/qt-dom/qtbase/src/corelib/kernel/qobject.h:13: In file included from /Users/sami/projects/qt-dom-build/qtbase/include/QtCore/qlist.h:1: In file included from /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qlist.h:11: In file included from /Users/sami/projects/qt-dom-build/qtbase/include/QtCore/qhashfunctions.h:1: /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qhashfunctions.h:398:12: error: no matching function for call to 'qHashMulti' 398 | return qHashMulti(seed, key.first, key.second); | ^~~~~~~~~~ /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qhash.h:59:16: note: in instantiation of function template specialization 'qHash<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>' requested here 59 | return qHash(t, seed); | ^ /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qhash.h:688:37: note: in instantiation of function template specialization 'QHashPrivate::calculateHash<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>>' requested here 688 | size_t hash = QHashPrivate::calculateHash(key, seed); | ^ /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qhash.h:1337:22: note: in instantiation of function template specialization 'QHashPrivate::Data<QHashPrivate::Node<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>, QQmlJS::Dom::CommentedElement>>::findBucket<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>>' requested here 1337 | auto it = d->findBucket(key); | ^ /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qhash.h:1353:16: note: in instantiation of function template specialization 'QHash<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>, QQmlJS::Dom::CommentedElement>::constFindImpl<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>>' requested here 1353 | return constFindImpl(key); | ^ /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qhash.h:1357:16: note: in instantiation of member function 'QHash<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>, QQmlJS::Dom::CommentedElement>::find' requested here 1357 | return find(key); | ^ /Users/sami/projects/qt-dom/qtdeclarative/src/qmldom/qqmldomcomments_p.h:259:45: note: in instantiation of member function 'QHash<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>, QQmlJS::Dom::CommentedElement>::constFind' requested here 259 | const auto it = m_commentedElements.constFind(CommentKey{n, location}); | ^ /Users/sami/projects/qt-dom/qtbase/src/corelib/tools/qhashfunctions.h:352:1: note: candidate template ignored: substitution failure [with T = <QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>]: no matching function for call to 'qHash' 325 | qHashMulti(size_t seed, const T &... args) | ^ 1 error generated.
when trying to implement qHash() on one of my classes:
// inside a private header struct CommentAnchor { qsizetype location = -1; friend bool comparesEqual(const CommentAnchor &a, const CommentAnchor &b) noexcept { return a.location == b.location; } Q_DECLARE_EQUALITY_COMPARABLE(CommentAnchor) }; size_t qHash(const CommentAnchor &key, size_t seed) noexcept { return qHashMulti(seed, key.location); }
Then, using QHash<std::pair<QQmlJS::AST::Node *, QQmlJS::Dom::CommentAnchor>, QQmlJS::Dom::CommentedElement> would lead to a compilation error. Using QHash<CommentAnchor, int> on the other hand compiles fine.
It turned that out that QHashCombine is used by qMultiHash and uses the one argument versions of qHash. Adding a default argument to size_t qHash(const CommentAnchor &key, size_t seed = 0) noexcept made the compilation work again.
Should the documentation at https://doc.qt.io/qt-6/qhash.html#the-hashing-function be fixed to mention the default argument, or should QHashCombine work with both one and two argument versions of qHash()?
Attachments
Issue Links
- resulted in
-
QTBUG-134690 qHashMulti and qHashMultiCommutative use the slower seed==0 algorithms for strings
-
- Open
-