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 15:37:37 +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
Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |NEW
Last reconfirmed| |2017-04-25
Resolution|INVALID |---
Ever confirmed|0 |1
Severity|normal |enhancement
--- Comment #7 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Paul Eggert from comment #6)
> > main always return according to the standard
>
> No, the C standard does not require 'main' to return. It's perfectly
> acceptable for 'main' to never return, and many programs are written that
> way.
>
> > what you are asking for is a non standard extension
>
> Any program that uses '__attribute__ ((__noreturn__))' is *already* using a
> nonstandard extension. It would be more useful if this nonstandard extension
> worked for 'main' like it does for other functions, because many 'main'
> functions in fact do not return.
main() may not return. But it has a return statement nonetheless.
Your example is equivalent to:
int main() {
for (;;)
;
return 0;
}
But Ok, clang and icc accept the noreturn attribute for main already.
So lets reopen as an enhancement.