Re: [HACKERS] more compile warnings
Tom Lane wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > You would think that would catch it. My problem is that I am compiling > > with -O0, because I compile all day and I don't care about optimization. > > You should reconsider that. At -O0 gcc doesn't do any flow analysis, > and thus you lose many important warnings. I'd recommend -O1 at least. Yes, I will re-add -O to my flags. When I did it I forgot it would affect warnings. In fact, I am now seeing a similar warning in python that I hadn't seen before, and others probably don't see it because they don't compile python. FYI, -O2 adds only 2 minutes to my 13 minute test script (but increases the cpu usage from 4 to 6 minutes). -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [HACKERS] more compile warnings
Bruce Momjian <[EMAIL PROTECTED]> writes: > You would think that would catch it. My problem is that I am compiling > with -O0, because I compile all day and I don't care about optimization. You should reconsider that. At -O0 gcc doesn't do any flow analysis, and thus you lose many important warnings. I'd recommend -O1 at least. regards, tom lane ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
Re: [HACKERS] more compile warnings
On Fri, Dec 06, 2002 at 11:16:30PM -0500, Bruce Momjian wrote: > > I use: > > -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align Some other useful ones are -pedantic -W -Wfloat-equal -Wshadow -Wcast-qual -Wwrite-strings -Wconversion -Wsign-compare -Wsign-promo. > You would think that would catch it. My problem is that I am compiling > with -O0, because I compile all day and I don't care about optimization. > In this case, the -O3 is doing some optimization that catches the > problem, while -O0 does not. Interesting. Even -O catches it. Last time I checked (which was admittedly some time ago) all the interesting analysis that could give you new warnings was done by -O; -O2 mostly involves the back-end, and -O3 adds pretty much nothing except aggressive inlining. Which was more likely to trigger compiler bugs at the time than to find anything in your code. Jeroen ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [HACKERS] more compile warnings
Dann Corbit wrote: > Instead of just assigning a value, it means it is conceivable that a > path allows undefined behavior. Example: > > ... > int y; > if (x < 5) >y = 3; > if (x > 5) >y = 1; > > What happens if x == 5? Then y is indeterminate. > Sometimes, the flow analysis just gets confused and it really will be > initialized along every path. But at least it bears checking. Hence > the warning. Yes, I looked at the code, and they are legitimate warnings. > I like to use -W -Wall -ansi -pedantic -O3 I use: -Wall -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wcast-align You would think that would catch it. My problem is that I am compiling with -O0, because I compile all day and I don't care about optimization. In this case, the -O3 is doing some optimization that catches the problem, while -O0 does not. Interesting. Even -O catches it. -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [HACKERS] more compile warnings
> -Original Message- > From: Bruce Momjian [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 06, 2002 7:58 PM > To: Joe Conway > Cc: [EMAIL PROTECTED]; PostgreSQL-development > Subject: Re: [HACKERS] more compile warnings > > > Rod, can you comment on these warnings Joe Conway's compiler > is showing? I don't see the warnings with gcc, but clearly > they look like problems. > > I can just assign a NULL on definition, but I thought you > should take a look. > > -- > - > > Joe Conway wrote: > > Hi Bruce, > > > > I just sync'd up/make clean/make all and get this: > > > > gcc -O2 -g -Wall -Wmissing-prototypes -Wmissing-declarations > > -I../../../src/include -c -o typecmds.o typecmds.c -MMD > > typecmds.c: In function `AlterDomainAddConstraint': > > typecmds.c:1237: warning: `ccbin' might be used > uninitialized in this > > function > > typecmds.c: In function `get_rels_with_domain': > > typecmds.c:1450: warning: `rtc' might be used uninitialized > in this function Instead of just assigning a value, it means it is conceivable that a path allows undefined behavior. Example: ... int y; if (x < 5) y = 3; if (x > 5) y = 1; What happens if x == 5? Then y is indeterminate. Sometimes, the flow analysis just gets confused and it really will be initialized along every path. But at least it bears checking. Hence the warning. I like to use -W -Wall -ansi -pedantic -O3 ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [HACKERS] more compile warnings
Rod, can you comment on these warnings Joe Conway's compiler is showing? I don't see the warnings with gcc, but clearly they look like problems. I can just assign a NULL on definition, but I thought you should take a look. --- Joe Conway wrote: > Hi Bruce, > > I just sync'd up/make clean/make all and get this: > > gcc -O2 -g -Wall -Wmissing-prototypes -Wmissing-declarations > -I../../../src/include -c -o typecmds.o typecmds.c -MMD > typecmds.c: In function `AlterDomainAddConstraint': > typecmds.c:1237: warning: `ccbin' might be used uninitialized in this function > typecmds.c: In function `get_rels_with_domain': > typecmds.c:1450: warning: `rtc' might be used uninitialized in this function -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]