|
Boost : |
From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 2000-03-20 11:41:39
Stephen Cleary wrote:
> 3) On platforms that support faults as exceptions (meaning division
> by zero, access violation/seg fault, etc.) it is often difficult or
> impossible to predict whether exceptions of this type will be
> (implicitly) thrown by any given piece of code.
[...]
> [1] No, not even operator T*() { return ptr; }. Consider contrived
> example:
> int * tmp = (shared_ptr<int> *)(0)->operator int *(); // may throw
> access violation/seg fault
>
> Now, of *course* no programmer would write such code, but the compiler
> cannot predict that "this" *isn't* some invalid value, so it must err
> on the side of caution.
Since this is undefined behaviour, it may do anything it wants.
-- Valentin Bonnard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk