Hi everyone, On 03/04/2023 07:04, LIU Hao wrote: > 在 2023/4/3 16:55, Vittorio Romeo 写道: >> Hello everyone, >> Hope you are doing well. >> >> I've encountered and reported a bug related to explicit template >> instantiations and dllexport using the latest version of GCC on >> MinGW/MSYS2: >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109380 > > I don't think it's a bug. There are two issues in your testcase, one is > that > > extern template struct __declspec(dllexport) S<int>; > > is a declaration, and nothing can be exported from a declaration (you > export the definition instead).
I believe this may be correct as per the standard, https://developercommunity.visualstudio.com/t/c11-extern-templates-doesnt-work-for-class-templat/157868#T-N355261 but not according to MinGW's own semantics: https://reviews.llvm.org/D61118 I recall we had to work around it in Krita to avoid a possible runtime symbol clash/crash: https://invent.kde.org/graphics/krita/-/commit/0ca27275ee9c8e7a4a2223cc4e66d12e95517edc > > The other is that `g()` is an implicit inline function. An inline > function can only be exported when it is emitted as a non-inline copy, > for example, when optimization is not enabled, or when its address is > taken, or when it is virtual and the class has a non-pure non-inline > virtual function (a.k.a. the key function) which instantiates its vtable. > > > > > > _______________________________________________ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public Best regards, amyspark -- amyspark 🌸 https://www.amyspark.me _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public