From patchwork Fri Oct 21 13:21:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 78664 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1298428qge; Fri, 21 Oct 2016 06:22:10 -0700 (PDT) X-Received: by 10.36.107.15 with SMTP id v15mr861454itc.88.1477056130028; Fri, 21 Oct 2016 06:22:10 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l5si2244939pan.265.2016.10.21.06.22.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Oct 2016 06:22:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-439232-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-439232-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-439232-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=ZuIR5JkvU/VzAOi8h D4vCjEZqK7a8Pb2VJE4I0IVOficwu/hp+hcV/P9VYFvEjKlWyWw3qOaIqbn8onRj /S6gYBqfN0Upz/84zzZzTchQEYvzCMMKHWJqwZIeCiqTowh12dnw81SlrV1N52uD mqdLPil6LFOQPiWGmyEhpvAZjo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=kOxh4PD9FXGEZq6FJNf6NqF qJ+k=; b=CFmRM9w7pUICJ4w9xJNVvjD354+8Vm+AvJFg3sNqcQlva5Leah+C90L v7+A0ZsUyhC5wcFW8A+d8iE8EhSqB3R1JZ5giXBkaMx0lRjRa9DcvWGaK+n5fgDx NYQpPO1HEo3nJGctTbfZ1FtolLP9KR/sx9KTLwPBikw63qiRIPks= Received: (qmail 27280 invoked by alias); 21 Oct 2016 13:21:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27224 invoked by uid 89); 21 Oct 2016 13:21:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=bah, bah!, 2010-2016 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Oct 2016 13:21:35 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61069C0567B2; Fri, 21 Oct 2016 13:21:34 +0000 (UTC) Received: from localhost (ovpn-116-70.ams2.redhat.com [10.36.116.70]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9LDLX34020204; Fri, 21 Oct 2016 09:21:34 -0400 Date: Fri, 21 Oct 2016 14:21:33 +0100 From: Jonathan Wakely To: Gleb Natapov Cc: Ryan Burn , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCHv2] do not throw in std::make_exception_ptr Message-ID: <20161021132133.GR2922@redhat.com> References: <20160805044923.GX17903@scylladb.com> <20160821122030.GC9243@scylladb.com> <20160822172935.GV20016@redhat.com> <20161021113653.GA26234@scylladb.com> <20161021114439.GO2922@redhat.com> <20161021115826.GD14913@scylladb.com> <20161021123350.GF18396@scylladb.com> <20161021125705.GQ2922@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161021125705.GQ2922@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.0 (2016-08-17) On 21/10/16 13:57 +0100, Jonathan Wakely wrote: >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 in my test. > >I'll make that change, thanks. Tested powerpc64le-linux, committed to trunk. commit 1e88a5c65a6158462d3703869766f973db91527f Author: Jonathan Wakely Date: Fri Oct 21 14:04:16 2016 +0100 Use global operator new in std::make_exception_ptr * libsupc++/exception_ptr.h (make_exception_ptr): Qualify new. * testsuite/18_support/exception_ptr/make_exception_ptr_2.cc: New test. diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index 21e4e8b..a47a585 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -187,10 +187,10 @@ namespace std { #if __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI void *__e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex)); - (void)__cxxabiv1::__cxa_init_primary_exception(__e, - const_cast(&typeid(__ex)), - __exception_ptr::__dest_thunk<_Ex>); - new (__e) _Ex(__ex); + (void)__cxxabiv1::__cxa_init_primary_exception( + __e, const_cast(&typeid(__ex)), + __exception_ptr::__dest_thunk<_Ex>); + ::new (__e) _Ex(__ex); return exception_ptr(__e); #else throw __ex; diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/make_exception_ptr_2.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/make_exception_ptr_2.cc new file mode 100644 index 0000000..3787777 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/make_exception_ptr_2.cc @@ -0,0 +1,43 @@ +// { dg-do run { target c++11 } } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2010-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// https://gcc.gnu.org/ml/libstdc++/2016-10/msg00139.html + +struct E { + void* operator new(std::size_t) = delete; +}; + +void test01() +{ + E e; + std::exception_ptr p = std::make_exception_ptr(e); + + VERIFY( p ); +} + +int main() +{ + test01(); + + return 0; +}