This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/80515] __attribute__ ((__noreturn__)) false alarm for 'main'
- From: "trippels at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 25 Apr 2017 14:58:18 +0000
- Subject: [Bug c/80515] __attribute__ ((__noreturn__)) false alarm for 'main'
- Auto-submitted: auto-generated
- References: <bug-80515-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80515
--- Comment #5 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Paul Eggert from comment #4)
> > main() has an implicit return 0.
>
> That's irrelevant to the purpose of the warning. The warning is there to
> catch the common typo of a function containing a return statement even
> though it is declared 'noreturn'. But there is no typo here.
>
> As it stands now, the 'main' function cannot have __attribute__
> ((__noreturn__)), even when 'main' is designed to never return. This
> restriction makes no sense from the user's point of view.
main always return according to the standard. If you don't use an
explicit return, the compiler will always add an implicit one.
So what you are asking for is a non standard extension.