lundiorg/lundi — pull request #12 by rmartinho (2013-04-23 15:57:10+00:00)
Title: Fix lua::exception to play nicer with other exception tools

Multiple inheritance with exceptions is a common pattern. It allows one to tack
additional behaviour to existing exceptions (see `std::throw_with_nested` or
`boost::exception`).

However, the designers of the standard exception hierarchy forgot about it and
all exceptions in the standard derive non-virtually from `std::exception`. That
leads to the following failure:
http://coliru.stacked-crooked.com/view?id=92b74ea7f51fae17a11371570914ea5b-14c8e563c8913f543c2e48c16b56f668

The problem in that snippet is that there are two `std::exception` objects in a
single `ab_error` object; which one should be bound in the catch? So
`std::terminate`.

The end result is that the only safe standard exception to derive from is
`std::exception`, and it should be done virtually, so that only one
`std::exception` object exits in each exception object.
http://coliru.stacked-crooked.com/view?id=5234f5ab5793c9f0c8f8e7159c1692cb-14c8e563c8913f543c2e48c16b56f668