I get this warning while compiling the class below (with %template(MyClassImpl) MyClass<int, int="">;).
Warning 317: Specialization of non-template 'MyClass'.
I think SWIG is misinterpreting the template definition of the constructor as a specialization for the class template.
template <typename T, typename U> struct MyClass { template<typename P> MyClass<T,D>(P p) { } };
Still reproducible with current git master.
As a workaround, you can omit the
<T,D>
on the constructor in this situation which SWIG does accept :SWIG also parses the original example if the
template<typename P>
is removed - that obviously changes the meaning but shows that the redundant template parameters on the constructor aren't the sole cause of this. So the problem here seems to be handling the combination of a constructor in a templated class itself being a template and having explicit ly listed template parameters from the class.Last edit: Olly Betts 2022-01-23
Still reproducible with current git master.
The original testcase needs a tweak to be valid C++ I think - presumably
D
should beU
otherwise GCC complains about it:But SWIG behaves the same with that fixed.
Corrected testcase:
Note that
MyClass<T,U>
is not valid syntax from C++20 onwards, but SWIG continues to support it.The warning no longer appears in master, so this issue is fixed for swig-4.2.0.
Great - 2ff9da0ce625eabf0dde3ffeaec075eba2c733a8 was the exact commit fixing this for the record.