On 14 Jun 2002, Guillaume Cottenceau wrote:
> Chris Rode <[EMAIL PROTECTED]> writes:
>
> [...]
>
> > float toot(int x, float y) {
> > if (y == 20) {
> > return y;
> > } else {
> > toot(x, x*y); (**)
> > }
> > }
> >
> >
> > Compiled with Red Hat's gcc 2.96, I get "nan" (however, If I take out
> > the recursive call, and just return x*y, I get 20.000000).
> >
> > Compiled with Debian's 2.95.4, I get 20.000000.
>
> If you compiled with "-Wall" you'd have seen that the line I
> marked with a (**) misses a "return"; currently, the function
> "toot" returns an "unspecified" value when y != 20, thus
> different versions of gcc may effectively produce different
> values.
>
> Conclusion, always compile with -Wall :-).
Oh, DUH. Now that you point it out, it's blindingly obvious. Thanks for
the help. :)
--Chris.
_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list