Re: 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
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Import Notes
Reply to msg id not found: 3DF1701A.5020509@joeconway.com
-----Original Message-----
From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
Sent: Friday, December 06, 2002 7:58 PM
To: Joe Conway
Cc: rbt@zort.ca; PostgreSQL-development
Subject: Re: [HACKERS] more compile warningsRod, 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 useduninitialized in this
function
typecmds.c: In function `get_rels_with_domain':
typecmds.c:1450: warning: `rtc' might be used uninitializedin 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
Import Notes
Resolved by subject fallback
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
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
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
Bruce Momjian <pgman@candle.pha.pa.us> 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
Tom Lane wrote:
Bruce Momjian <pgman@candle.pha.pa.us> 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
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073