Article View: comp.unix.programmer
Article #3524Re: Should C/C++ compilers be smart enough to catch this???
From: Måns Rullgård
Date: Thu, 03 Apr 2003 21:14
Date: Thu, 03 Apr 2003 21:14
33 lines
2257 bytes
2257 bytes
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
Technical Details
Message-ID:
<yw1x65pvfflm.fsf@zaphod.guide>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uio.no!news.kth.se!not-for-mailReferences:
<3E8C8C4F.ABC60B0F@doe.carleton.ca>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 13:27:45 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uio.no!news.kth.se!not-for-mail From: mru@users.sourceforge.net (Måns Rullgård) Newsgroups: comp.unix.programmer,gnu.gcc.help Subject: Re: Should C/C++ compilers be smart enough to catch this??? Date: 03 Apr 2003 23:14:45 +0200 Lines: 33 Sender: mru@zaphod.guide Message-ID: <yw1x65pvfflm.fsf@zaphod.guide> References: <3E8C8C4F.ABC60B0F@doe.carleton.ca> NNTP-Posting-Host: manganonaujakasit.e.kth.se Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Portable Code)