Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.6.1, 6.6.2, 6.6.3
-
None
-
Seen on Linux, macOS, Windows. Clang 15 and 16 but this should get triggered under other compilers too.
-
-
c8db469fd (dev), 7d12cf673 (6.7), 8da0980ae (6.6)
Description
The problem code is in corelib/mimetypes/qmimeprovider.cpp.
From https://github.com/llvm/llvm-project/issues/74963#issuecomment-1850834221:
"~unique_ptr() became constexpr in C++23 and thus gets instantiated more eagerly – at the point of first reference rather than at end of TU."
Fix:
Make the definition of QMimeBinaryProvider::CacheFile precede the definition of QMimeBinaryProvider::QMimeBinaryProvider() because the unique_ptr<QMimeBinaryProvider::CacheFile> QMimeBinaryProvider::m_cacheFile will be instantiated at this point and thus also ~unique_ptr<QMimeBinaryProvider::CacheFile>() which needs the definition of QMimeBinaryProvider::CacheFile to be visible.
Compiler command line (summarised, obviously):
clang++ -Wall -O3 -std=c++2b
-Wno-unqualified-std-cast-call -finput-charset=UTF-8
-o build/QtCore/mimetypes/qmimeprovider.dylib.o
-c -x c++ src/QtCore/mimetypes/qmimeprovider.cpp
Error message:
In file included from /src/QtCore/mimetypes/qmimeprovider.cpp:6: In file included from /src/QtCore/private/QtCore/private/qmimeprovider_p.h:19: In file included from /src/QtCore/private/QtCore/private/qmimedatabase_p.h:19: In file included from /src/QtCore/qmimedatabase.h:8: In file included from /src/QtCore/qmimetype.h:12: In file included from /src/QtCore/qobjectdefs.h:13: In file included from /src/QtCore/qobjectdefs_impl.h:17: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:898: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:31: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:63:19: error: invalid application of 'sizeof' to an incomplete type 'QMimeBinaryProvider::CacheFile' static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type"); ^~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:297:7: note: in instantiation of member function 'std::default_delete<QMimeBinaryProvider::CacheFile>::operator()' requested here __ptr_.second()(__tmp); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:263:75: note: in instantiation of member function 'std::unique_ptr<QMimeBinaryProvider::CacheFile>::reset' requested here _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); } ^ /src/QtCore/mimetypes/qmimeprovider.cpp:66:22: note: in instantiation of member function 'std::unique_ptr<QMimeBinaryProvider::CacheFile>::~unique_ptr' requested here QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db, const QString &directory) ^ /src/QtCore/private/QtCore/private/qmimeprovider_p.h:112:12: note: forward declaration of 'QMimeBinaryProvider::CacheFile' struct CacheFile;