[cfe-users] clang-cl fails to link program with deleted copy constructor

via cfe-users cfe-users at lists.llvm.org
Tue May 2 08:35:28 PDT 2017


Given this program:

#include <iostream>

class X : public std::runtime_error
{
public:
     X() : std::runtime_error("X") {}
     ~X() override = default;
     X(const X& other) = delete;
     X& operator = (const X&) = delete;
     X(X&& other) : std::runtime_error(other.what()) {}
};

int main(int argc, char const *argv[])
{
     try
     {
         std::cout << "Throwing X\n";
         throw X{};
     }
     catch (const X& x)
     {
         std::cout << "Caught X\n";
         std::cerr << x.what() << "\n";
         return EXIT_FAILURE;
     }
     std::cout << "Should never get here...\n";
     return EXIT_SUCCESS;
}

Compiling with

     clang-cl /EHsc /GR main.cpp

gives me a link error about X(X& x) not being present. However, 
compiling with

     cl /EHsc /GR main.cpp

it works just fine. The code that triggers this error is not mine and I 
cannot modify it. Is there any workaround for this?

clang version 5.0.0 (trunk)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin

Using Visual Studio 14 2015 along with it.



More information about the cfe-users mailing list