incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: std::length_error in language support library
Date Mon, 31 Aug 2009 23:41:23 GMT
On 08/31/2009 01:26 PM, Martin Sebor wrote:
> On 08/21/2009 10:34 AM, Farid Zaripov wrote:
>> Looking at the latest draft of the C++ standard (n2914.pdf) it appears,
>> that
>> the std::length_error can be defined in language support library.
>> This is the result of resolution of the CWG issue #624:
> That's a problem. Let me see if there's any willingness among
> the committee to revert it to bad_alloc.

It turns out that there already is an issue to revert this change:

If Microsoft implemented the resolution of issue 624 they will
need to revert it. Ditto if they throw length_error from standard
functions that aren't allowed to throw it. In particular, if they
throw it (or any other exceptions) from any std::shared_ptr
operation they are in violation of 18.8.5 Exception Propagation
[propagation], p2:

   -2- exception_ptr shall be DefaultConstructible, CopyConstructible,
       CopyAssignable, and EqualityComparable. exception_ptr’s
       operations shall not throw exceptions.

If you can devise a test case that triggers an exception from any
shared_ptr operation in the Microsoft implementation it would be
enough to file a bug report with them and might help convince them
to take std::length_error out of the runtime library.

> Martin
>> 5.4.3 p7:
>> --------------
>> 7 When the value of the expression in a noptr-new-declarator is zero, the
>> allocation function is called to
>> allocate an array with no elements. If the value of that expression is
>> such
>> that the size of the allocated object
>> would exceed the implementation-defined limit, no storage is obtained and
>> the new-expression terminates
>> by throwing an exception of a type that would match a handler (15.3)
>> of type
>> std::length_error (19.2.4).
>> --------------
>> Farid

View raw message