When attempting to cross compile from Linux to Windows a DLL that uses variadic templates, this happens:
$ cat foo.cpp
template <typename e="std::logic_error," typename="" cond,="" typename...="" args="">
void check(Cond&& condition, Args&&... args) {
if (!static_cast<bool>(condition)) {
throw E(std::forward<args>(args)...);
}
}</args></bool></typename>
void foo(int i) {
check(i >= 0, "i is negative");
}
$ x86_64-w64-mingw32-g++ -O3 -flto -std=c++11 foo.cpp -shared -o foo.dll
Cannot export Z5checkISt11logic_errorbIRA14_KcEEvOT0_DpOT1: symbol wrong type (4 vs 3)
collect2: error: ld returned 1 exit status
I'm running these versions:
$ x86_64-w64-mingw32-g++ --version
x86_64-w64-mingw32-g++ (GCC) 5.1.0
...
$ x86_64-w64-mingw32-ld --version
GNU ld (GNU Binutils) 2.25
...
Passing -fno-use-linker-plugin works around the issue; unfortunately, that's not an option for me as my build process uses LTO with static libraries.
Sorry, didn't realise SourceForge uses markdown.