From 687685f64928ed69b2161f9f2ff4f303bec04967 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 23 Mar 2021 22:29:53 +0100 Subject: QTypeInfo: Handle T::value_type being equal to T Fix operator checks for containers whose value_type equals themselves. It does not make sense to recurse on value_type in that case. Thanks to std::disjunction having short-circuiting semantics, we can avoid that issue by checking first whether T is T::value_type. As a drive-by, check for value_type typedef before checking for begin/end in is_container. This works around an issue in gcc <= 8.1, which fails to correctly SFINAE the case where begin and end are private methods. Fixes: QTBUG-89456 Change-Id: I27305a7cfe050f13a279c07f00bc229c01daa25b Reviewed-by: Ulf Hermann (cherry picked from commit ce83e56cfeb2806181ec1daade9690f4c90b901c) Reviewed-by: Thiago Macieira --- tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index b49f770919..f5820ead88 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -2775,5 +2775,15 @@ Q_DECLARE_METATYPE(UndefinedFunction2); Q_DECLARE_METATYPE(UndefinedFunction3); Q_DECLARE_METATYPE(UndefinedFunction4); +struct S { + using value_type = S; // used to cause compilation error with Qt6 + int begin(); + int end(); +}; + +// should not cause a compilation failure +// used to cause issues due to S being equal to S::value_type +Q_DECLARE_METATYPE(S) + QTEST_MAIN(tst_QMetaType) #include "tst_qmetatype.moc" -- cgit v1.2.3