From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128641 invoked by alias); 15 Apr 2019 17:09:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 128630 invoked by uid 89); 15 Apr 2019 17:09:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Received:600c, prevent X-HELO: mail-wm1-f41.google.com Received: from mail-wm1-f41.google.com (HELO mail-wm1-f41.google.com) (209.85.128.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Apr 2019 17:09:21 +0000 Received: by mail-wm1-f41.google.com with SMTP id y197so9616443wmd.0 for ; Mon, 15 Apr 2019 10:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=q7O/vuBt+l9wRGoh55gokW8CN7jcKqVmhUy8PRxQFRA=; b=Y1XQbNZ2rJdIHDxB0ocPuCl4mA6XALN9HRAieyCH+ta/MQ13Slz5J1zVbz0d3dtcPU 01/jLn73MtOcJz46Ufj1xSVNEKl5Rr//k3Kv1XZDs4NTaoe1d3nR3xPfrFvwz1z9YR2W tSxtIUUwjm+HcyE4JjLdp5nNKmSdYTXmRtVBDYyei4AmskClslhu4CxojQMgx4tSdUmE 1cpZUtX6uc6vqyYYCPPRTJyQ5lz5bS1gsnUd9u7naZ03IRsYxuPhEfwSb6pM3PokVzq/ geWjCWyZPteM7TxR63sn/GZv8DUnpR8GLSxwsJ9yCuvuAMy3iuBlYUk+FvFZTsdvfQZt RstQ== MIME-Version: 1.0 References: <20190412212426.3411-1-jason@redhat.com> <856ddc06-d2f2-b18b-3ac5-b32f45339545@redhat.com> In-Reply-To: From: Andrew Pinski Date: Mon, 15 Apr 2019 17:39:00 -0000 Message-ID: Subject: Re: [PATCH] (RFA tree-tailcall) PR c++/82081 - tail call optimization breaks noexcept To: Richard Biener Cc: Jeff Law , Jason Merrill , GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00595.txt.bz2 On Sun, Apr 14, 2019 at 11:50 PM Richard Biener wrote: > > On Sat, Apr 13, 2019 at 12:34 AM Jeff Law wrote: > > > > On 4/12/19 3:24 PM, Jason Merrill wrote: > > > If a noexcept function calls a function that might throw, doing the tail > > > call optimization means that an exception thrown in the called function > > > will propagate out, breaking the noexcept specification. So we need to > > > prevent the optimization in that case. > > > > > > Tested x86_64-pc-linux-gnu. OK for trunk or hold for GCC 10? This isn't a > > > regression, but it is a straightforward fix for a wrong-code bug. > > > > > > * tree-tailcall.c (find_tail_calls): Don't turn a call from a > > > nothrow function to a might-throw function into a tail call. > > I'd go on the trunk. It's a wrong-code issue, what we're doing is just > > plain wrong. One could even make a case for backporting to the branches. > > Hmm, how's this different from adding another indirection? That is, > I don't understand why the tailcall is the issue here, shouldn't unwind > still stop at the noexcept caller? Thus, isn't this wrong CFI instead? noexcept caller is no longer on the stack so the unwinder does not see it. It is not the tail call from a normal function to a noexcept that is an issue but rather inside a noexcept caller to a normal function. > > Of course I know to little about this. > > Btw, doesn't your check also prevent tail/sibling calls when > the caller wraps it into a try { } catch (...) {}? Or does unwind > not work in that case either? > > Btw, I'd like to see a runtime testcase that fails. There is one in the bug report. Though it would not work for the testsuite. It should not be hard to change it to be one that works for the testsuite. Thanks, Andrew Pinski > > Richard. > > > jeff > > > > ps. I'm a bit surprised it hasn't been reported until now.