🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3526

Re: Should C/C++ compilers be smart enough to catch this???

#3526
From: Fred Ma
Date: Thu, 03 Apr 2003 22:15
56 lines
3138 bytes
M�ns Rullg�rd wrote:

> Fred Ma <fma@doe.carleton.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@users.sf.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@doe.carleton.ca
Carleton University, Dept. of Electronics
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6
Technical Details
Message-ID: <3E8CB293.44FCA73@doe.carleton.ca>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!torn!cunews!not-for-mail
References: <3E8C8C4F.ABC60B0F@doe.carleton.ca> <yw1x65pvfflm.fsf@zaphod.guide>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 11318c,2ca0bb2ef0ae6ada
X-Google-Attributes: gid11318c,public
X-Google-Thread: fc89c,2ca0bb2ef0ae6ada
X-Google-Attributes: gidfc89c,public
X-Google-ArrivalTime: 2003-04-03 14:20:24 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!torn!cunews!not-for-mail
From: Fred Ma <fma@doe.carleton.ca>
Newsgroups: comp.unix.programmer,gnu.gcc.help
Subject: Re: Should C/C++ compilers be smart enough to catch this???
Date: 3 Apr 2003 22:15:48 GMT
Organization: Carleton University, Ottawa, Canada
Lines: 59
Message-ID: <3E8CB293.44FCA73@doe.carleton.ca>
References: <3E8C8C4F.ABC60B0F@doe.carleton.ca> <yw1x65pvfflm.fsf@zaphod.guide>
NNTP-Posting-Host: malawi.doe.carleton.ca
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Mailer: Mozilla 4.77 [en] (X11; U; SunOS 5.8 sun4u)
X-Accept-Language: en
To: cygwin@cygwin.com