This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin 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: Should C/C++ compilers be smart enough to catch this???


Måns Rullgård wrote:

> Fred Ma <fma at doe dot carleton dot ca> 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
> mru at users dot sf dot net

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, fma at doe dot carleton dot ca
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/


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