I have been several post with something similar to my problem but I can't figure out how to solve it in my implementation.
It's about a custom exception classes that compile perfectly in Linux with gcc 9, but in MacOs (Catalina) with Clang 11.0.3 fails dramatically.
Here is the code:
#include <stdexcept>
class Exception : public std::runtime_error
{
public:
Exception() : std::runtime_error("mt library error") {}
Exception(const std::string& what_arg) : std::runtime_error(what_arg) {}
};
/// Division by zero exception.
class ZeroDivide : public Exception
{
public:
ZeroDivide() : Exception("Division by near-zero value") {}
};
When compile in MacOS I get the error:
error: no matching constructor for initialization of 'mt::Exception'
ZeroDivide() : Exception("Division by near-zero value") {}
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and different notes like:
candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const char [36]' to 'const mt::Exception' for 1st argument
and other errors derived from the first one when I try to throw the exception like:
Exception("Normalizing interval is ill defined")
I have seen some examples like this of how could fix the problem but I can not figure out how to reimplement mine in order to make it work in MacOs
Somebody can help me?
Thanks in advance.
Edit
As the project is big, I have created a repository here with a minimal example to reproduce the error, you just have to compile following this steps
mkdir build
cd build
cmake ..
make