diff mbox

[PATCHv2] do not throw in std::make_exception_ptr

Message ID 20161021113653.GA26234@scylladb.com
State New
Headers show

Commit Message

Gleb Natapov Oct. 21, 2016, 11:36 a.m. UTC
On Thu, Oct 20, 2016 at 11:53:49PM -0400, Ryan Burn wrote:
> Are exception classes required to support emplace new construction
> like that? With this change, Intel's TBB library no longer compiles
> because its exception class declares it's own new operator (see
> https://github.com/wjakob/tbb/blob/master/include/tbb/tbb_exception.h):
> 
Can you test this patch please:


> 
> class tbb_exception : public std::exception
> {
>     /** No operator new is provided because the TBB usage model assumes dynamic
>          creation of the TBB exception objects only by means of applying move()
>          operation on an exception thrown out of TBB scheduler. **/
>     void* operator new ( size_t );
> ....
> 
> 
> On Mon, Aug 22, 2016 at 1:29 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> > On 21/08/16 15:20 +0300, Gleb Natapov wrote:
> >>
> >> Jonathan,
> >>
> >> Is this version OK with you?
> >
> >
> > I've committed the attached version, which just adds some whitespace
> > and fixes the testsuite_abi.cc test.
> >
> > Thanks very much for the improvement to the code.
> >

--
			Gleb.

Comments

Jonathan Wakely Oct. 21, 2016, 11:44 a.m. UTC | #1
On 21/10/16 14:36 +0300, Gleb Natapov wrote:
>On Thu, Oct 20, 2016 at 11:53:49PM -0400, Ryan Burn wrote:
>> Are exception classes required to support emplace new construction
>> like that? With this change, Intel's TBB library no longer compiles
>> because its exception class declares it's own new operator (see
>> https://github.com/wjakob/tbb/blob/master/include/tbb/tbb_exception.h):
>>
>Can you test this patch please:

That doesn't help, the overloaded new still prevents placement new.
Dammit.

I'll see what we can do ...
Jonathan Wakely Oct. 21, 2016, 11:45 a.m. UTC | #2
On 21/10/16 12:44 +0100, Jonathan Wakely wrote:
>On 21/10/16 14:36 +0300, Gleb Natapov wrote:
>>On Thu, Oct 20, 2016 at 11:53:49PM -0400, Ryan Burn wrote:
>>>Are exception classes required to support emplace new construction
>>>like that? With this change, Intel's TBB library no longer compiles
>>>because its exception class declares it's own new operator (see
>>>https://github.com/wjakob/tbb/blob/master/include/tbb/tbb_exception.h):
>>>
>>Can you test this patch please:
>
>That doesn't help, the overloaded new still prevents placement new.
>Dammit.
>
>I'll see what we can do ...


We should be able to us SFINAE to detect when the placement
new-expression is valid.
Gleb Natapov Oct. 21, 2016, 11:58 a.m. UTC | #3
On Fri, Oct 21, 2016 at 12:44:39PM +0100, Jonathan Wakely wrote:
> On 21/10/16 14:36 +0300, Gleb Natapov wrote:
> > On Thu, Oct 20, 2016 at 11:53:49PM -0400, Ryan Burn wrote:
> > > Are exception classes required to support emplace new construction
> > > like that? With this change, Intel's TBB library no longer compiles
> > > because its exception class declares it's own new operator (see
> > > https://github.com/wjakob/tbb/blob/master/include/tbb/tbb_exception.h):
> > > 
> > Can you test this patch please:
> 
> That doesn't help, the overloaded new still prevents placement new.
> Dammit.
> 
Hmm, are you sure. This program compiles for me (while fails without ::):

#include<new>
#include <stdlib.h>

struct S {
  void* operator new (unsigned long size);
};

main() {
 void* p = malloc(sizeof(S));
 ::new(p) S();
}

--
			Gleb.
Gleb Natapov Oct. 21, 2016, 12:33 p.m. UTC | #4
On Fri, Oct 21, 2016 at 02:58:26PM +0300, Gleb Natapov wrote:
> On Fri, Oct 21, 2016 at 12:44:39PM +0100, Jonathan Wakely wrote:
> > On 21/10/16 14:36 +0300, Gleb Natapov wrote:
> > > On Thu, Oct 20, 2016 at 11:53:49PM -0400, Ryan Burn wrote:
> > > > Are exception classes required to support emplace new construction
> > > > like that? With this change, Intel's TBB library no longer compiles
> > > > because its exception class declares it's own new operator (see
> > > > https://github.com/wjakob/tbb/blob/master/include/tbb/tbb_exception.h):
> > > > 
> > > Can you test this patch please:
> > 
> > That doesn't help, the overloaded new still prevents placement new.
> > Dammit.
> > 
> Hmm, are you sure. This program compiles for me (while fails without ::):
> 
Looks like tbb also compiles and pass tests.

> #include<new>
> #include <stdlib.h>
> 
> struct S {
>   void* operator new (unsigned long size);
> };
> 
> main() {
>  void* p = malloc(sizeof(S));
>  ::new(p) S();
> }
> 
> --
> 			Gleb.

--
			Gleb.
Jonathan Wakely Oct. 21, 2016, 12:57 p.m. UTC | #5
On 21/10/16 15:33 +0300, Gleb Natapov wrote:
>On Fri, Oct 21, 2016 at 02:58:26PM +0300, Gleb Natapov wrote:
>> On Fri, Oct 21, 2016 at 12:44:39PM +0100, Jonathan Wakely wrote:
>> > On 21/10/16 14:36 +0300, Gleb Natapov wrote:
>> > > On Thu, Oct 20, 2016 at 11:53:49PM -0400, Ryan Burn wrote:
>> > > > Are exception classes required to support emplace new construction
>> > > > like that? With this change, Intel's TBB library no longer compiles
>> > > > because its exception class declares it's own new operator (see
>> > > > https://github.com/wjakob/tbb/blob/master/include/tbb/tbb_exception.h):
>> > > >
>> > > Can you test this patch please:
>> >
>> > That doesn't help, the overloaded new still prevents placement new.
>> > Dammit.
>> >
>> Hmm, are you sure. This program compiles for me (while fails without ::):
>>
>Looks like tbb also compiles and pass tests.

Bah! I didn't include <new> in my test.

I'll make that change, thanks.


>> #include<new>
>> #include <stdlib.h>
>>
>> struct S {
>>   void* operator new (unsigned long size);
>> };
>>
>> main() {
>>  void* p = malloc(sizeof(S));
>>  ::new(p) S();
>> }
>>
>> --
>> 			Gleb.
>
>--
>			Gleb.
diff mbox

Patch

diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h
index 21e4e8b..6ade626 100644
--- a/libstdc++-v3/libsupc++/exception_ptr.h
+++ b/libstdc++-v3/libsupc++/exception_ptr.h
@@ -190,7 +190,7 @@  namespace std
           (void)__cxxabiv1::__cxa_init_primary_exception(__e,
                                            const_cast<std::type_info*>(&typeid(__ex)),
                                            __exception_ptr::__dest_thunk<_Ex>);
-          new (__e) _Ex(__ex);
+          ::new (__e) _Ex(__ex);
           return exception_ptr(__e);
 #else
           throw __ex;