From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Julian Waters <tanksherman27@gmail.com>
Cc: Andrew Pinski <pinskia@gmail.com>, gcc@gcc.gnu.org
Subject: Re: Warning specifically for a returning noreturn
Date: Wed, 5 Jul 2023 12:26:07 +0100 [thread overview]
Message-ID: <CAH6eHdQU3=i9P=SgU85xkBWB5VbP6c32o5E+3FPumB5uZQ5LbA@mail.gmail.com> (raw)
In-Reply-To: <CAP2b4GN9v-tmrCbzydjdOoL4VCW28TpYHjAW8Qxwb9W9OpRLHg@mail.gmail.com>
On Wed, 5 Jul 2023 at 12:01, Julian Waters via Gcc <gcc@gcc.gnu.org> wrote:
>
> I see, thanks Andrew.
>
> Anyone else have opinions on this besides Liu or Andrew? The responses have
> 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, <pinskia@gmail.com> wrote:
>
> > On Tue, Jul 4, 2023 at 6:32 PM Julian Waters <tanksherman27@gmail.com>
> > 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 unreachable
> > 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#index-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 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 11:27 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
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 [this message]
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='CAH6eHdQU3=i9P=SgU85xkBWB5VbP6c32o5E+3FPumB5uZQ5LbA@mail.gmail.com' \
--to=jwakely.gcc@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=pinskia@gmail.com \
--cc=tanksherman27@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).