[PATCH RFC] do not throw in std::make_exception_ptr

Jonathan Wakely jwakely@redhat.com
Wed Aug 3 12:36:00 GMT 2016


On 03/08/16 15:02 +0300, Gleb Natapov wrote:
>On Wed, Aug 03, 2016 at 12:47:30PM +0100, Jonathan Wakely wrote:
>> Huh. If I'm reading the ABI spec correctly, we should terminate if the
>> copy constructor throws.
>>
>I'll make it terminate like you've suggested then.

Let's leave it as you had it originally. I'm not sure if my reading of
the ABI is correct, so let's keep the behaviour consistent for now.

We can always revisit it later if we decide terminating is correct.

>> We don't seem to do that even without exception_ptr involved:
>>
>Yes, that's the reason current make_exception_ptr behaves as it does,
>but to fix your test case below the code that generates code for 'throw'
>will have to be fixed.

Right, and we wont' be changing that as part of this patch, so let's
stay consistent with that too.

>> #include <iostream>
>> #include <exception>
>>
>> struct E {
>>    E()  {}
>>    E(const E&) { throw 5; }
>> };
>>
>> int main() {
>>    static E e;
>>    try {
>>        throw e;
>>    } catch(E& ep) {
>>        std::cout << "E" << std::endl;
>>    } catch (int& i) {
>>        std::cout << "int" << std::endl;
>>    }
>> }
>[skip]
>> > > > -  std::type_info *exceptionType;
>> > > > +  const std::type_info *exceptionType;
>> > > >   void (_GLIBCXX_CDTOR_CALLABI *exceptionDestructor)(void *);
>> > >
>> > > The __cxa_exception type is defined by
>> > > https://mentorembedded.github.io/cxx-abi/abi-eh.html#cxx-data and this
>> > > doesn't conform to that spec. Is this change necessary?
>I missed this comment. typeid() returns const std::type_info so I
>either need to add const here or cast the const away from  typeid()
>return value.

Please use const_cast. std::type_info doesn't have any non-cosnt
member that would allow modifications through that pointer anyway.

Thanks.



More information about the Gcc-patches mailing list