Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
19 Views

Throwing an implicit move-only class leads to linker error.

Intel Compiler 19.4. The following code compiles cleanly on MSVC and GCC: #include #include struct MyClass{ std::unique_ptr<:STRING> node; }; int main(){ throw MyClass(); } But when compiled with ICC 19.4, it leads to: 1>Main.obj : : error LNK2001: unresolved external symbol "public: __cdecl MyClass::MyClass(struct MyClass const &)" (??0MyClass@@QEAA@AEBU0@@Z) 1>C:\Users\Kotori\Desktop\Test Project\x64\Release\Test Project.exe : : error LNK1120: 1 unresolved externals It looks like the compiler is trying to call the implicitly deleted copy-constructor instead of the move-constructor.
0 Kudos
4 Replies
Highlighted
Moderator
19 Views

seems like #include ... are missing header files. 

0 Kudos
Highlighted
Novice
19 Views

Argh, I forgot to format as code. It should be this:

#include <memory>
#include <string>

struct MyClass{
    std::unique_ptr<std::string> node;
};

int main(){
    throw MyClass();
}

It seems only repro on Windows. I'm unable to repro it on Godbolt - which I presume is Linux.

 

0 Kudos
Highlighted
Moderator
19 Views

I reproduced it on Windows. Let me take a look at it and will get back to you.

0 Kudos
Highlighted
Moderator
19 Views

I've reported it to our developer. The internal bug number is: CMPLRIL0-31912

0 Kudos