more compile warnings

more compile warnings

Post by Bruce Momji » Sun, 08 Dec 2002 12:58:15



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.

---------------------------------------------------------------------------


> 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

  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------

 
 
 

more compile warnings

Post by Dann Corbi » Sun, 08 Dec 2002 13:10:35


> -----Original Message-----

> Sent: Friday, December 06, 2002 7:58 PM
> To: Joe Conway

> Subject: Re: [HACKERS] more compile warnings
>=20
>=20
> Rod, can you comment on these warnings Joe Conway's compiler=20
> is showing? I don't see the warnings with gcc, but clearly=20
> they look like problems.
>=20
> I can just assign a NULL on definition, but I thought you=20
> should take a look.
>=20
> --------------------------------------------------------------
> -------------
>=20

> > Hi Bruce,
> >=20
> > I just sync'd up/make clean/make all and get this:
> >=20
> > gcc -O2 -g -Wall -Wmissing-prototypes -Wmissing-declarations=20
> > -I../../../src/include   -c -o typecmds.o typecmds.c -MMD
> > typecmds.c: In function `AlterDomainAddConstraint':
> > typecmds.c:1237: warning: `ccbin' might be used=20
> uninitialized in this=20
> > function
> > typecmds.c: In function `get_rels_with_domain':
> > typecmds.c:1450: warning: `rtc' might be used uninitialized=20
> 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)=20
   y =3D 3;
 if (x > 5)
   y =3D 1;

What happens if x =3D=3D 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)---------------------------


 
 
 

more compile warnings

Post by Bruce Momji » Sun, 08 Dec 2002 13:16:54



> 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.

Quote:> 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

  +  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

message can get through to the mailing list cleanly

 
 
 

more compile warnings

Post by Jeroen T. Vermeule » Sun, 08 Dec 2002 13:35:45



> 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.

Quote:> 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)---------------------------

 
 
 

more compile warnings

Post by Tom La » Mon, 09 Dec 2002 06:14:56



> 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

 
 
 

more compile warnings

Post by Bruce Momji » Wed, 11 Dec 2002 03:45:12




> > 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

  +  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

 
 
 

1. fix compile warning in pg_id

Patch applied.  Thanks.

---------------------------------------------------------------------------

[ Attachment, skipping... ]

--
  Bruce Momjian                        |  http://candle.pha.pa.us

  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

2. ANN: Java Database Publishing Servlet

3. compile warnings in CVS

4. SDO_GEOMETRY and PRO*C++

5. compile warnings in CVS HEAD

6. Backups larger than 2gb

7. compile warnings

8. Sybase SQL ANYWHERE

9. 4gl compile warning/error ..

10. 4GL Compile Warning: Global CSE elimination ....

11. fix compile warning in pg_id

12. WARNING WARNING WARNING

13. warning compiling ADOX objects whit import directive VC++