From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id C54843858408 for ; Wed, 5 Jul 2023 11:27:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C54843858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-977e0fbd742so769738266b.2 for ; Wed, 05 Jul 2023 04:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688556378; x=1691148378; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Tvwtg2ivRm9xli2LAEBXE7qaRFDmTb77IJ6UX8cnSnY=; b=l7pYmD6Zb477wZQejcstCw8If6l279OGLeXcvyUYYTETdxq09ZL1ZugNijLHuhCx/k f4lUtsIGIxSqA8lpgrY6fj9smim8Hg/+KCefDgpvrBnPs4RZNELi6MpDDvoTbPIstgGg dsJEEMN1hV2eaqHG5kaACQ77k8PEMEsoYe0WI6I+neCCRVAG/DcrpQ9y8UjYXTdS/njx wHV4kp6vcQMVr0bmv8EgbH4v2+9dZKPSxbx7oUyccin83CGbGmWnScE/YRrhyvTktccm wM0Vcm0cHde1x9zW9y8m4VOCNfU8WEjZYbyOELaVJYKdV6qT8eVbjkZ9oyQ0BNz0TLnI 0Krw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688556378; x=1691148378; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tvwtg2ivRm9xli2LAEBXE7qaRFDmTb77IJ6UX8cnSnY=; b=hjO8OKKPf0PENbbI5WWymMfVWxbORu1KwbxP7r33C79XzJgEyuGM1Y9lL4sFHCeT0a IV6fk6LEEBeEebBDQYcNtUwO1nWr33h0IGnZ2pwqgvIsxEuTUtY8W0z0tEzN32OTl1+m lFTe3cbNSloY9WuJngwyQFKT7p7RFfjwlVaVxBQ7ggXFMX503CTV4HtiJaVBkIW9hx5B n7gBV0Llk1eiuGSa8WXbt/A/EjlN8scSjc46IWq5lAYadEvwUeeMi9V3490iifw5iKUG Y0hdu+y+9T70rjvuCvICrX0D418/G5lUxl1U5ee/THiB+q7YW6oB0jRuOYDmuekL02yO 4Clg== X-Gm-Message-State: AC+VfDx24j4mSpHhDJiyeJd2u4lhHZ2kbjkSfHSjueH7jj7upNOVDeVD 4iMPGjDXFgY+K01759Ug+FusbDtucDoda5AQzIU= X-Google-Smtp-Source: APBJJlHZkoxzd/HIiOQzTNzXzT7muyuDKBHsNE8fXmZ/elnR6hlCOLoohZJRAv+9CP9oSgDFXhMSIZmyAVOXdcTIalo= X-Received: by 2002:a17:906:4e06:b0:98d:dd76:7201 with SMTP id z6-20020a1709064e0600b0098ddd767201mr11229101eju.16.1688556378474; Wed, 05 Jul 2023 04:26:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 5 Jul 2023 12:26:07 +0100 Message-ID: Subject: Re: Warning specifically for a returning noreturn To: Julian Waters Cc: Andrew Pinski , gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 5 Jul 2023 at 12:01, Julian Waters via Gcc wrote: > > I see, thanks Andrew. > > Anyone else have opinions on this besides Liu or Andrew? The responses ha= ve > been surprisingly quiet thus far IMHO all warnings should have an option controlling them, so that you can disable them via pragmas. But I agree that you shouldn't need to return from a noreturn function, it can either throw or use __builtin_unreachable() on the line where you currently return. > > best regards, > Julian > > On Wed, 5 Jul 2023, 09:40 Andrew Pinski, wrote: > > > On Tue, Jul 4, 2023 at 6:32=E2=80=AFPM Julian Waters > > wrote: > > > > > > Hi Andrew, thanks for the quick response, > > > > > > What if the method has a return value? I know it sounds > > counterintuitive, but in some places HotSpot relies on the noreturn > > attribute being applied to methods that do return a value in an unreach= able > > code path. Does the unreachable builtin cover that case too? > > > > It is wrong to use noreturn on a function other than one which has a > > return type of void as documented. > > > > https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#inde= x-noreturn-function-attribute > > : > > ``` > > It does not make sense for a noreturn function to have a return type > > other than void. > > ``` > > > > Thanks, > > Andrew Pinski > > > > > > > > > > best regards. > > > Julian > > > > > > On Wed, Jul 5, 2023 at 9:07=E2=80=AFAM Andrew Pinski wrote: > > >> > > >> On Tue, Jul 4, 2023 at 5:54=E2=80=AFPM Julian Waters via Gcc > > wrote: > > >> > > > >> > Hi all, > > >> > > > >> > Currently to disable the warning that a noreturn method does retur= n, > > it's > > >> > required to disable warnings entirely. This can be very inconvenie= nt > > when > > >> > -Werror is enabled with a noreturn method that isn't specifically > > calling > > >> > something like std::abort() at the end, when one wants all other > > -Wall and > > >> > -Wextra warnings to be reported, for instance in the Java HotSpot = VM > > (which > > >> > I'm currently adapting to compile with gcc on all supported > > platforms). Is > > >> > there a possibility we can add a disable warning option specifical= ly > > for > > >> > this case? Something like -Wno-returning-noreturn. I'm interested = in > > adding > > >> > this myself if it's not convenient for gcc's maintainers to do so = at > > the > > >> > moment, but I'd need some guidance on where to look and what the > > relevant > > >> > code is > > >> > > >> You could just add > > >> __builtin_unreachable(); (or std::unreachable(); if you are C++23 or > > >> unreachable() if you are using C23). > > >> Or even add while(true) ; > > >> > > >> I am pretty sure not having an option is on purpose and not really > > >> interested in adding an option here because of the above workarounds= . > > >> > > >> Thanks, > > >> Andrew Pinski > > >> > > >> > > > >> > best regards, > > >> > Julian > >