This is the mail archive of the gcc-patches@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]

Re: [PATCH] Loop bug generates invalid code on s390


On Wed, Dec 17, 2003 at 01:11:45AM +0100, Ulrich Weigand wrote:
> > > This is not required by the C standard.  (C99: 5.1.2.2.3)
> > 
> > Only C99+ though, and you are not passing -std=c99 nor -std=gnu99.
> > GCC only adds implicit return 0 if -std={c,gnu}99.
> 
> While I don't have the C89 standard, I had been under the 
> impression that the implicit return 0 was OK there as well.
> 
> And I've just verified that gcc accepts
>   int main (void) { }
> without warning and generates code to return 0 even with
>   -Wall -Wextra -std=c89 -pedantic

Are you sure?

$ ./xgcc -B ./ -v
Reading specs from ./specs
Configured with: ../configure --host i386-redhat-linux --target
i386-redhat-linux --enable-languages=c,c++
Thread model: posix
gcc version 3.4 20031215 (experimental)
$ echo 'int main () {}' | ./xgcc -B ./ -std=c89 -pedantic -W -Wall -xc - -o test; ./test; echo $?
<stdin>: In function `main':

<stdin>:1: warning: control reaches end of non-void function
16
$ echo 'int main () {}' | ./xgcc -B ./ -std=c99 -pedantic -W -Wall -xc - -o test; ./test; echo $?
0

#ifdef DEFAULT_MAIN_RETURN
          /* Make it so that `main' always returns success by default.  */
          DEFAULT_MAIN_RETURN;
#else
          if (flag_isoc99)
            c_expand_return (integer_zero_node);
#endif


	Jakub


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