12 Feb
2016
12 Feb
'16
12:50 a.m.
Gavin Lambert wrote:
On 12/02/2016 13:02, Peter Dimov wrote:
That's not true. The class author decided that calling operator* on a NULL pointer is a logic error and therefore a correct program should never do so. This doesn't have anything to do with performance; it's a question of design.
Then why doesn't it throw a logic_error?
Because throwing a logic_error is an oxymoron. Logic errors should not throw.
Or call abort()?
That's basically what it does. Or a crash when asserts are disabled.
Again, an assert is a useful tool in debug mode but it disappears in release mode. The only reason to elide this check is for performance.
That's correct.