This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


805. Which exception to throw for overflow in array size calculation

Section:  []     Status: CD2     Submitter: UK     Date: 3 March, 2009

N2800 comment UK 72
N2800 comment UK 192

[Voted into WP at July, 2009 meeting as part of N2932.]

Throwing std::length_error ( [] paragraph 7) for an attempt to allocate a too-large array brings in too much of the Standard library. A simpler exception, like std::bad_alloc, should be thrown instead.

Notes from the March, 2009 meeting:

The CWG was in favor of throwing an exception derived from std::bad_alloc. This would be upwardly compatible; it would be harmless for programs that currently catch std::bad_alloc, but would allow programs to treat the calculation overflow case separately if they wish.