Re: [HACKERS] --enable-debug

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] --enable-debug
Date: 2000-01-26 06:01:40
Message-ID: 16267.948866500@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> Currently, I believe -Wall is turned on automatically if your compiler
>> is gcc --- at least it seems to work that way on my platform (maybe
>> it's in the hpux_gcc template?). Anyway I get a pretty good set of -W
>> options without doing anything special.

> I remember when we removed every warning gcc -Wall complained about.

Um, did we stop?

In my experience, gcc is an excellent detector of portability problems.
I believe that it is good practice to crank gcc's warning level out
to the max, and to fix everything that it complains about.

Some gcc warnings are not really portability problems. For example,
it may gripe about "variable X may be used without being initialized"
when a human can easily see from the code logic that X will not actually
get read in any execution path that it wasn't previously set in.
Still, I'm willing to shut gcc up by adding a redundant initialization
of X, rather than turning down its warning level or making a habit of
ignoring what it says. If you go down one of those other paths you
are likely to miss warnings that could have saved you from genuine bugs.

In short: I like to see Postgres compile with no warnings at all
even with a very anal-retentive set of gcc settings.

Just to give you an idea of what I consider anal-retentive ;-),
here is what I customarily compile the IJG JPEG sources with:

CFLAGS= -g -O2 -ansi -Wall -Wtraditional -Wshadow -Wwrite-strings \
-Wpointer-arith -Wbad-function-cast -Wcast-qual -Wid-clash-15 \
-Wstrict-prototypes -Wmissing-prototypes
# -Wconversion would be nice, but it complains about some stdio macros on HPUX

Before any release I also eliminate any warnings shown by several
other Unix and PC compilers cranked out to their max warning levels.
I believe that this practice has helped to make libjpeg one of the
most portable libraries on the planet.

Compiler warnings can be your friend. Use 'em.

regards, tom lane
organizer, Independent JPEG Group

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2000-01-26 06:04:12 Re: [HACKERS] --enable-debug
Previous Message Bruce Momjian 2000-01-26 05:46:43 Many files modified tonight