Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

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

AYee1
Novice
494 Views
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
Viet_H_Intel
Moderator
494 Views

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

0 Kudos
AYee1
Novice
494 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
Viet_H_Intel
Moderator
494 Views

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

0 Kudos
Viet_H_Intel
Moderator
494 Views

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

0 Kudos
Reply