From: Julian Waters <tanksherman27@gmail.com>
To: Andrew Pinski <pinskia@gmail.com>, gcc@gcc.gnu.org
Subject: Re: Warning specifically for a returning noreturn
Date: Wed, 5 Jul 2023 09:31:36 +0800 [thread overview]
Message-ID: <CAP2b4GMjgdUrmDyYGVZ+f+3kqJs-_HqGqD2AxVU21HMhig8z5Q@mail.gmail.com> (raw)
In-Reply-To: <CA+=Sn1ny9X=DuseAsJ30_Yu-dgQyGThtfgZ25FGK730hWiMc7g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]
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 unreachable code path. Does the
unreachable builtin cover that case too?
best regards.
Julian
On Wed, Jul 5, 2023 at 9:07 AM Andrew Pinski <pinskia@gmail.com> wrote:
> On Tue, Jul 4, 2023 at 5:54 PM Julian Waters via Gcc <gcc@gcc.gnu.org>
> wrote:
> >
> > Hi all,
> >
> > Currently to disable the warning that a noreturn method does return, it's
> > required to disable warnings entirely. This can be very inconvenient 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 specifically 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
>
next prev parent reply other threads:[~2023-07-05 1:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 0:52 Julian Waters
2023-07-05 1:07 ` Andrew Pinski
2023-07-05 1:31 ` Julian Waters [this message]
2023-07-05 1:40 ` Andrew Pinski
2023-07-05 5:40 ` LIU Hao
2023-07-05 11:00 ` Julian Waters
2023-07-05 11:26 ` Jonathan Wakely
2023-07-05 13:13 ` Julian Waters
2023-07-05 13:20 ` Jonathan Wakely
2023-07-21 3:26 ` Julian Waters
2023-07-21 9:43 ` Jonathan Wakely
2023-07-25 2:38 ` Julian Waters
2023-07-05 16:50 ` Eric Gallager
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAP2b4GMjgdUrmDyYGVZ+f+3kqJs-_HqGqD2AxVU21HMhig8z5Q@mail.gmail.com \
--to=tanksherman27@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=pinskia@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).