list::_M_check_equal_allocators throws
Jonathan Wakely
jwakely.gcc@gmail.com
Tue Sep 17 15:52:00 GMT 2013
On 17 September 2013 16:30, Marc Glisse wrote:
> On Tue, 17 Sep 2013, Jonathan Wakely wrote:
>
>> On 17 September 2013 14:57, Marc Glisse wrote:
>>>
>>> Hello,
>>>
>>> I noticed that std::list::_M_check_equal_allocators throws an exception
>>> when
>>> the allocators should be equal but they are not. This prevents from
>>> marking
>>> splice noexcept (well, technically we still could, but...).
>>>
>>> Debug mode, when it detects an error, prints a diagnostic and aborts.
>>> Should
>>> this list check do the same? It looks more like a logic error than a
>>> runtime
>>> error to me.
>>
>>
>> I agree that std::logic_error would have made more sense than
>> std::runtime_error, but as it's undefined behaviour anyway I'd be
>> happy to just terminate there too. I don't have a strong preference.
>
>
> By "just terminate", are you happy with replacing the exception with a
> simple __builtin_abort()
Yes, that's what I was thinking.
> (or an explicit call to std::terminate?) or do you
> still want some form of error reporting? I don't think we want to include
> iostream or even stdio in <list>, so printing a diagnostic is complicated.
Agreed.
> There is the possibility to leave the throw there, mark the function as
> noexcept, and rely on the sad fact that this should call terminate, but I
> don't like that much.
Agreed again.
I support adding noexcept specifications to places that shouldn't
throw, even if that prevents us using exceptions to identify undefined
behaviour, like this case. Others might disagree though, and prefer
having an exception thrown, so I'm interested to hear what other
people think.
More information about the Libstdc++
mailing list