This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/80515] __attribute__ ((__noreturn__)) false alarm for 'main'


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]