You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Farid Zaripov <fa...@apache.org> on 2009/08/21 18:34:20 UTC

std::length_error in language support library

  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:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#624

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


Re: std::length_error in language support library

Posted by Martin Sebor <ms...@gmail.com>.
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:
>> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#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:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#805

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
>>
>


Re: std::length_error in language support library

Posted by Martin Sebor <ms...@gmail.com>.
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:
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#624

That's a problem. Let me see if there's any willingness among
the committee to revert it to bad_alloc.

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
>