Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.0.3
-
None
-
64bfc927b09b46bb7fc0dc6caf1bf1a4d4133ab4 (qt/qtbase/dev)
Description
This code builds fine with Qt5:
#include <QPair> #include <QSet> #include <QString> int main() { QSet<QPair<QString, QPair<int, int>>> s; s.insert(qMakePair(QString(), qMakePair(1, 2))); }
With Qt 6, I get:
In file included from /usr/include/qt6/QtCore/qhash.h:44, from /usr/include/qt6/QtCore/qset.h:43, from /usr/include/qt6/QtCore/QSet:1, from /tmp/blubb/main.cpp:2: /usr/include/qt6/QtCore/qhashfunctions.h: In instantiation of ‘size_t qHash(const std::pair<_T1, _T2>&, size_t) [with T1 = QString; T2 = std::pair<int, int>; size_t = long unsigned int]’: /usr/include/qt6/QtCore/qhashfunctions.h:98:41: required by substitution of ‘template<class T> constexpr const bool QHashPrivate::HasQHashSingleArgOverload<T, typename std::enable_if<is_convertible_v<decltype (qHash(declval<const T&>())), long unsigned int>, void>::type> [with T = std::pair<QString, std::pair<int, int> >]’ /usr/include/qt6/QtCore/qhashfunctions.h:177:54: required by substitution of ‘template<class T, typename std::enable_if<HasQHashSingleArgOverload<T>, bool>::type <anonymous> > size_t qHash(const T&, size_t) [with T = std::pair<QString, std::pair<int, int> >; typename std::enable_if<HasQHashSingleArgOverload<T>, bool>::type <anonymous> = <missing>]’ /usr/include/qt6/QtCore/qhash.h:548:28: required from ‘QHashPrivate::Data<Node>::iterator QHashPrivate::Data<Node>::find(const Key&) const [with Node = QHashPrivate::Node<std::pair<QString, std::pair<int, int> >, QHashDummyValue>; QHashPrivate::Data<Node>::iterator = QHashPrivate::iterator<QHashPrivate::Node<std::pair<QString, std::pair<int, int> >, QHashDummyValue> >; QHashPrivate::Data<Node>::Key = std::pair<QString, std::pair<int, int> >]’ /usr/include/qt6/QtCore/qhash.h:590:23: required from ‘QHashPrivate::Data<Node>::InsertionResult QHashPrivate::Data<Node>::findOrInsert(const Key&) [with Node = QHashPrivate::Node<std::pair<QString, std::pair<int, int> >, QHashDummyValue>; QHashPrivate::Data<Node>::Key = std::pair<QString, std::pair<int, int> >]’ /usr/include/qt6/QtCore/qhash.h:1125:38: required from ‘QHash<Key, T>::iterator QHash<Key, T>::emplace(Key&&, Args&& ...) [with Args = {const QHashDummyValue&}; Key = std::pair<QString, std::pair<int, int> >; T = QHashDummyValue]’ /usr/include/qt6/QtCore/qhash.h:1117:23: required from ‘QHash<Key, T>::iterator QHash<Key, T>::emplace(const Key&, Args&& ...) [with Args = {const QHashDummyValue&}; Key = std::pair<QString, std::pair<int, int> >; T = QHashDummyValue]’ /usr/include/qt6/QtCore/qhash.h:1095:23: required from ‘QHash<Key, T>::iterator QHash<Key, T>::insert(const Key&, const T&) [with Key = std::pair<QString, std::pair<int, int> >; T = QHashDummyValue]’ /usr/include/qt6/QtCore/qset.h:181:68: required from ‘QSet<T>::iterator QSet<T>::insert(const T&) [with T = std::pair<QString, std::pair<int, int> >]’ /tmp/blubb/main.cpp:8:51: required from here /usr/include/qt6/QtCore/qhashfunctions.h:274:64: error: no matching function for call to ‘qHash(const std::pair<int, int>&, size_t&)’ 274 | noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) | ~~~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/qt6/QtCore/qstringview.h:58, from /usr/include/qt6/QtCore/qchar.h:665, from /usr/include/qt6/QtCore/qstring.h:50, from /usr/include/qt6/QtCore/qhashfunctions.h:44, from /usr/include/qt6/QtCore/qhash.h:44, from /usr/include/qt6/QtCore/qset.h:43, from /usr/include/qt6/QtCore/QSet:1, from /tmp/blubb/main.cpp:2: /usr/include/qt6/QtCore/qbytearray.h:721:43: note: candidate: ‘size_t qHash(const QByteArray::FromBase64Result&, size_t)’ 721 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray::FromBase64Result &key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qbytearray.h:721:85: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘const QByteArray::FromBase64Result&’ 721 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray::FromBase64Result &key, size_t seed = 0) noexcept; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/qt6/QtCore/qhash.h:44, from /usr/include/qt6/QtCore/qset.h:43, from /usr/include/qt6/QtCore/QSet:1, from /tmp/blubb/main.cpp:2: /usr/include/qt6/QtCore/qhashfunctions.h:106:47: note: candidate: ‘constexpr size_t qHash(char, size_t)’ 106 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(char key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:106:58: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘char’ 106 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(char key, size_t seed = 0) noexcept | ~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:108:47: note: candidate: ‘constexpr size_t qHash(uchar, size_t)’ 108 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(uchar key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:108:59: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘uchar’ {aka ‘unsigned char’} 108 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(uchar key, size_t seed = 0) noexcept | ~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:110:47: note: candidate: ‘constexpr size_t qHash(signed char, size_t)’ 110 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(signed char key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:110:65: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘signed char’ 110 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(signed char key, size_t seed = 0) noexcept | ~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:112:47: note: candidate: ‘constexpr size_t qHash(ushort, size_t)’ 112 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(ushort key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:112:60: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘ushort’ {aka ‘short unsigned int’} 112 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(ushort key, size_t seed = 0) noexcept | ~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:114:47: note: candidate: ‘constexpr size_t qHash(short int, size_t)’ 114 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(short key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:114:59: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘short int’ 114 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(short key, size_t seed = 0) noexcept | ~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:116:47: note: candidate: ‘constexpr size_t qHash(uint, size_t)’ 116 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(uint key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:116:58: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘uint’ {aka ‘unsigned int’} 116 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(uint key, size_t seed = 0) noexcept | ~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:118:47: note: candidate: ‘constexpr size_t qHash(int, size_t)’ 118 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(int key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:118:57: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘int’ 118 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(int key, size_t seed = 0) noexcept | ~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:120:47: note: candidate: ‘constexpr size_t qHash(ulong, size_t)’ 120 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(ulong key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:120:59: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘ulong’ {aka ‘long unsigned int’} 120 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(ulong key, size_t seed = 0) noexcept | ~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:122:47: note: candidate: ‘constexpr size_t qHash(long int, size_t)’ 122 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(long key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:122:58: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘long int’ 122 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(long key, size_t seed = 0) noexcept | ~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:124:47: note: candidate: ‘constexpr size_t qHash(quint64, size_t)’ 124 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(quint64 key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:124:61: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘quint64’ {aka ‘long long unsigned int’} 124 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(quint64 key, size_t seed = 0) noexcept | ~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:130:47: note: candidate: ‘constexpr size_t qHash(qint64, size_t)’ 130 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(qint64 key, size_t seed = 0) noexcept { return qHash(quint64(key), seed); } | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:130:60: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘qint64’ {aka ‘long long int’} 130 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(qint64 key, size_t seed = 0) noexcept { return qHash(quint64(key), seed); } | ~~~~~~~^~~ In file included from /usr/include/qt6/QtCore/qhash.h:44, from /usr/include/qt6/QtCore/qset.h:43, from /usr/include/qt6/QtCore/QSet:1, from /tmp/blubb/main.cpp:2: /usr/include/qt6/QtCore/qhashfunctions.h:131:37: note: candidate: ‘size_t qHash(float, size_t)’ 131 | Q_DECL_CONST_FUNCTION inline size_t qHash(float key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:131:49: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘float’ 131 | Q_DECL_CONST_FUNCTION inline size_t qHash(float key, size_t seed = 0) noexcept | ~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:139:44: note: candidate: ‘size_t qHash(double, size_t)’ 139 | Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(double key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:139:57: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘double’ 139 | Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(double key, size_t seed = 0) noexcept; | ~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:141:44: note: candidate: ‘size_t qHash(long double, size_t)’ 141 | Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(long double key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:141:62: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘long double’ 141 | Q_CORE_EXPORT Q_DECL_CONST_FUNCTION size_t qHash(long double key, size_t seed = 0) noexcept; | ~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:143:47: note: candidate: ‘constexpr size_t qHash(wchar_t, size_t)’ 143 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(wchar_t key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:143:61: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘wchar_t’ 143 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(wchar_t key, size_t seed = 0) noexcept | ~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:145:47: note: candidate: ‘constexpr size_t qHash(char16_t, size_t)’ 145 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(char16_t key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:145:62: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘char16_t’ 145 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(char16_t key, size_t seed = 0) noexcept | ~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:147:47: note: candidate: ‘constexpr size_t qHash(char32_t, size_t)’ 147 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(char32_t key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:147:62: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘char32_t’ 147 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(char32_t key, size_t seed = 0) noexcept | ~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:153:34: note: candidate: ‘template<class T> size_t qHash(const T*, size_t)’ 153 | template <class T> inline size_t qHash(const T *key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:153:34: note: template argument deduction/substitution failed: /usr/include/qt6/QtCore/qhashfunctions.h:274:64: note: mismatched types ‘const T*’ and ‘std::pair<int, int>’ 274 | noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) | ~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:157:47: note: candidate: ‘constexpr size_t qHash(std::nullptr_t, size_t)’ 157 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(std::nullptr_t, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:157:53: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘std::nullptr_t’ 157 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(std::nullptr_t, size_t seed = 0) noexcept | ^~~~~~~~~~~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:163:47: note: candidate: ‘constexpr size_t qHash(QChar, size_t)’ 163 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(const QChar key, size_t seed = 0) noexcept { return qHash(key.unicode(), seed); } | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:163:65: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘QChar’ 163 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(const QChar key, size_t seed = 0) noexcept { return qHash(key.unicode(), seed); } | ~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:164:43: note: candidate: ‘size_t qHash(const QByteArray&, size_t)’ 164 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray &key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:164:67: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘const QByteArray&’ 164 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray &key, size_t seed = 0) noexcept; | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:165:43: note: candidate: ‘size_t qHash(const QByteArrayView&, size_t)’ 165 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArrayView &key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:165:71: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘const QByteArrayView&’ 165 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QByteArrayView &key, size_t seed = 0) noexcept; | ~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:166:43: note: candidate: ‘size_t qHash(QStringView, size_t)’ 166 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QStringView key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:166:61: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘QStringView’ 166 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QStringView key, size_t seed = 0) noexcept; | ~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:168:36: note: candidate: ‘size_t qHash(const QString&, size_t)’ 168 | inline Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:168:57: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘const QString&’ 168 | inline Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) noexcept | ~~~~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:171:43: note: candidate: ‘size_t qHash(const QBitArray&, size_t)’ 171 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:171:66: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘const QBitArray&’ 171 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept; | ~~~~~~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:172:43: note: candidate: ‘size_t qHash(QLatin1String, size_t)’ 172 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1String key, size_t seed = 0) noexcept; | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:172:63: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘QLatin1String’ 172 | Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1String key, size_t seed = 0) noexcept; | ~~~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:173:47: note: candidate: ‘constexpr size_t qHash(QKeyCombination, size_t)’ 173 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(QKeyCombination key, size_t seed = 0) noexcept | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:173:69: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘QKeyCombination’ 173 | Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(QKeyCombination key, size_t seed = 0) noexcept | ~~~~~~~~~~~~~~~~^~~ /usr/include/qt6/QtCore/qhashfunctions.h:178:8: note: candidate: ‘template<class T, typename std::enable_if<HasQHashSingleArgOverload<T>, bool>::type <anonymous> > size_t qHash(const T&, size_t)’ 178 | size_t qHash(const T &t, size_t seed) noexcept(noexcept(qHash(t))) | ^~~~~ /usr/include/qt6/QtCore/qhashfunctions.h:178:8: note: template argument deduction/substitution failed: /usr/include/qt6/QtCore/qhashfunctions.h:177:92: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’ 177 | template <typename T, std::enable_if_t<QHashPrivate::HasQHashSingleArgOverload<T>, bool> = true> | ^~~~
Attachments
For Gerrit Dashboard: QTBUG-92910 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
343803,2 | QHash: fix qHash(std::pair) | dev | qt/qtbase | Status: MERGED | +2 | 0 |