|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2000-07-17 08:38:42
----- Original Message -----
From: "Greg Colvin" <greg_at_[hidden]>
> As Beman noted:
>
> > smart_ptr.hpp has throw specifiers on a number of time-critical inline
> > functions such as dereferencing:
Yes, and on these particular functions the exception-specifications arguably
can only hurt, not help.
Consider:
None of these functions calls other functions; they only manipulate
fundamental data types like pointers
Therefore, no runtime behavior of the exception-specification can ever be
invoked
They are completely exposed to the compiler; indeed they're declared inline
Therefore, a smart compiler can easily deduce that the functions are
incapable of throwing exceptions, and make the same optimizations it would
have made based on the empty exception-specification.
A "dumb" compiler, however, could make all kinds of pessimizations, as we
have seen.
I'm just trying to show once again that although initially appealing, an
exception-specification tends to have consequences that require _very_
careful thought to understand.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk