...
The copy constructor for an object thrown as an exception must be declared noexcept(true)
, including any implicitly-defined copy constructors. Note, any function declared noexcept(true)
that terminates by throwing an exception violates ERR55-CPP. Honor exception specifications.
...
In this noncompliant code example, an exception of type S
is thrown from f()
. However, because S
has a std::string
data member, and the copy constructor for std::string
is not declared noexcept(true)
, the implicitly defined copy constructor for S
is also not declared to be noexcept(true)
. In low-memory situations, the copy constructor for std::string
may be unable to allocate sufficient memory to complete the copy operation, resulting in a std::bad_alloc
exception being thrown.
...