Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4.2
-
None
Description
Q_DECLARE_METATYPE(std::shared_ptr<int>) gives error on QT6, works on QT5.
A 'hello world' example that reproduces the issue is attached.
To reproduce the issue compile like this:
mkdir build; cd build; cmake ..; make
Plese note the following:
1. The example works on QT5.
2. The compiler gives an error about template specialization afer instantiation.
3. The issue was reported first in May 17, 2022 with a minimal example (also attacched with this bug report).
I am also able to reproduce the bug .
https://forum.qt.io/topic/136589/strange-moc-related-error-with-q_declare_metatype
In file included from /var/tmp/meta_issue/build/MetaTypeIssue_autogen/mocs_compilation.cpp:3:
In file included from /var/tmp/meta_issue/build/MetaTypeIssue_autogen/EWIEGA46WW/moc_m.cpp:10:
/var/tmp/meta_issue/build/MetaTypeIssue_autogen/EWIEGA46WW/../../../m.h:14:1: error: explicit specialization of 'QMetaTypeId<std::shared_ptr<int>>' after instantiation
Q_DECLARE_METATYPE(std::shared_ptr<int>);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/lib/QtCore.framework/Headers/qmetatype.h:1399:34: note: expanded from macro 'Q_DECLARE_METATYPE'
#define Q_DECLARE_METATYPE(TYPE) Q_DECLARE_METATYPE_IMPL(TYPE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/lib/QtCore.framework/Headers/qmetatype.h:1403:12: note: expanded from macro 'Q_DECLARE_METATYPE_IMPL'
struct QMetaTypeId< TYPE > \
^~~~~~~~~~~~~~~~~~~
/opt/homebrew/lib/QtCore.framework/Headers/qmetatype.h:1122:22: note: implicit instantiation first required here
enum { Defined = QMetaTypeId<T>::Defined, IsBuiltIn=false };