Article View: comp.unix.programmer
Article #3530Re: Should C/C++ compilers be smart enough to catch this???
From: Fred Ma
Date: Fri, 04 Apr 2003 08:36
Date: Fri, 04 Apr 2003 08:36
46 lines
2844 bytes
2844 bytes
Eric Sosman wrote: > Fred Ma wrote: > > > > 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. > > Try using both -W and -Wall; the latter's name suggests > that it's enabling "all" warnings, but that's not so. > > Also, -O2 (or higher) in conjunction with these can > produce warnings that will help locate uses of uninitialized > variables. > > For code that can tolerate it (some perfectly good code > cannot), consider adding -ansi. > > -- > Eric.Sosman@sun.com Thanks, again, all. I in for a bit of man page reading and code cleaning. Fred > -------- Original Message -------- > Subject: Re: Should C/C++ compilers be smart enough to catch this??? > Date: Thu, 03 Apr 2003 23:23:26 GMT > From: "KJK::Hyperion" > Organization: [Infostrada] > Newsgroups: comp.unix.programmer,gnu.gcc.help > References: <3E8C8C4F.ABC60B0F@doe.carleton.ca> > > > Shouldn't compilers be smart enough to not create code that corrupts > > when it is pretty straighforward to realize that (1) there is an > > obvious discrepancy, for which a warning can easily be issued, > > did you try the -W -Wall options? AFAIR, no return statement in a non- > void function *is* a candidate for a warning (e.g. the Borland compiler > is especially smart to catch such execution path-related bugs), altough > GCC by default is somewhat quiet >
Technical Details
Message-ID:
<3E8D4407.24FB5BEA@doe.carleton.ca>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mailReferences:
<3E8C8C4F.ABC60B0F@doe.carleton.ca> <yw1x65pvfflm.fsf@zaphod.guide> <3E8CB293.44FCA73@doe.carleton.ca> <3E8CBA21.3BC2B23F@sun.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit 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-04 00:43:10 PST Message-ID: <3E8D4407.24FB5BEA@doe.carleton.ca> From: Fred Ma <fma@doe.carleton.ca> X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.unix.programmer,gnu.gcc.help Subject: Re: Should C/C++ compilers be smart enough to catch this??? References: <3E8C8C4F.ABC60B0F@doe.carleton.ca> <yw1x65pvfflm.fsf@zaphod.guide> <3E8CB293.44FCA73@doe.carleton.ca> <3E8CBA21.3BC2B23F@sun.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 47 Date: Fri, 04 Apr 2003 03:36:24 -0500 NNTP-Posting-Host: 64.230.67.158 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1049445646 64.230.67.158 (Fri, 04 Apr 2003 03:40:46 EST) NNTP-Posting-Date: Fri, 04 Apr 2003 03:40:46 EST Organization: Bell Sympatico Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail