develooper Front page | perl.perl5.porters | Postings from April 2006

another handy tip for code police: with gcc -Wall, use -O

Thread Next
From:
Jarkko Hietaniemi
Date:
April 29, 2006 00:48
Subject:
another handy tip for code police: with gcc -Wall, use -O
Message ID:
44531AAF.8030601@gmail.com
Without the -O certain code checks don't kick in, most importantly
the warning about the use of uninitialised variables:

$ cat x.c
int main() {
  int a = 3;
  int b;
  return a + b;
}
$ gcc -Wall -o x x.c
$ ./x; echo $?
67
$ gcc -Wall -O -o x x.c
x.c: In function `main':
x.c:3: warning: `b' might be used uninitialized in this function
$

I guess the excuse for nothing doing this check in standard -Wall
is that only by engaging the optimiser enough data flow analysis
gets done to detect such naughty things.

If you feel like debugging, -Doptimize="-O -g" should work fine.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About