[geos-devel] Effects of using -g and -O2 together
mateusz at loskot.net
Thu Jul 6 13:04:17 EDT 2006
I noticed that GEOS' ./configure scripts called with
--enable-cassert=yes (GEOS equivalent of --enable-debug=yes)
sets CFLAGS as follows:
CFLAGS = -g -O2 -Wall -ansi -pedantic -Wno-long-long
As you see, this will produce debug version of optimized code.
It is not forbidden, but according to GCC manual, it can produce
some side and unexpected effects:
"GCC allows you to use -g with -O. The shortcuts taken by optimized code
may occasionally produce surprising results: some variables you declared
may not exist at all; flow of control may briefly move where you did not
expect it; some statements may not be executed because they compute
constant results or their values were already at hand; some statements
may execute in different places because they were moved out of loops."
I'd suggest to remove -O2 option if --enable-cassert is passed to
What do you think?
More information about the geos-devel