|
Boost : |
From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-06-29 19:18:33
On Thu, 29 Jun 2006 22:54:23 +0300, "Peter Dimov" <pdimov_at_[hidden]>
wrote:
>You can't relax an exception specification in an overrider, only tighten it,
>so yes, system_error::what() needs throw(). I believe that a conforming
>compiler will reject it without the throw() specification.
Your belief is right :-) The program is ill-formed per 15.4/3. To me
this is a good argument for using no-throw specifications on virtual
functions, if they don't throw.
It's perhaps worth noting that compiler-declared special member
functions (e.g. destructor) have an implicit exception specification
which as strict as the directly called functions allow for (not more,
not less). Thus, for instance, the following is ok:
struct my_ex : public std::exception
{
//~my_ex() {}
};
but it becomes ill-formed if you uncomment the destructor definition.
If a special member is virtual then the compiler-generated declaration
may render the program ill-formed exactly because, for the rule above,
it may relax the exception specification.
--Gennaro.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk