Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3E8CB293.44FCA73@doe.carleton.ca> Date: Thu, 03 Apr 2003 17:15:47 -0500 From: Fred Ma X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.unix.programmer,gnu.gcc.help To: cygwin AT cygwin DOT com Subject: Re: Should C/C++ compilers be smart enough to catch this??? References: <3E8C8C4F DOT ABC60B0F AT doe DOT carleton DOT ca> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Måns Rullgård wrote: > Fred Ma 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/