Subject: Re: Should C/C++ compilers be smart enough to catch this???
From: Fred Ma <[email-masked]>
To: [email-masked]
Date: Thu, 03 Apr 2003 17:15:47 -0500
Newsgroups: comp.unix.programmer,gnu.gcc.help

Måns Rullgård wrote:

> Fred Ma <[email-masked]> writes:
>
> > I had a class member function that returned an object, according to
> > the prototype.  Also according to the function definition.  But, the
> > function body didn't actually contain a return statement.  Like
> > SomeFunc() below:
>
> [snip]
>
> > The frustrating thing is that the compiler didn't complain at all
> > about the discrepancy between the lack of a return statement, even
> > though the function needed one.  I personally find this kind of
> > thing quite common when I reorganize my code e.g. moving
> > functionality in and out of class member functions; that is, the
> > finger details like return types and argument lists change so that
> > it's easy to miss.
>
> Always compile your stuff with -Wall.  That should enable the warning.
>
> > P.S.  Since this happens only on cygwin, it might specific to any
> > customizations to g++ for cygwin.  All in all, cygwin's gcc is a
> > much better indication of whether my code is buggy, because the
> > solaris executables generally seem to run fine even when there are
> > cringe- inducing bugs, which I only find because they crash on
> > cygwin.
>
> One could argue that it is the cygwin environment that is buggy, since
> it causes programs to crash, even though they run correctly on
> solaris.
>
> --
> Måns Rullgård
> [email-masked]

Thanks for the tip about -Wall.  I never realized I had so much
problem with my code until I turned it on.  I thought I was being
high and mighty righteous-like with -pedantic, but it looks like
there is a higher righteousness.  Lots of good reading, too, of
the man page.

Despite the comment about buggy cygwin, I am all too thankful
that I can compare the execution on the two platforms (solaris
and cygwin).  Whenever they disagree, I may curse the heavens
for spending days to find out why, but it invariably uncovers a
big performance/correctness bug which really, really needs to
be fixed.

Fred

--
Fred Ma, [email-masked]
Carleton University, Dept. of Electronics
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/