Hammer on snapshot cd's
Matthew Dillon
dillon at apollo.backplane.com
Tue Jul 15 11:57:51 PDT 2008
:How the heck can a compiler "miss" this? I thought whenever there
:existed a possible execution path which would not initialize the
:variable, it would complain.
:
:cheers
: simon
Meh. It isn't really GCC's fault. Frankly up until a few years ago
compilers generally didn't even try to check such use cases beyond
simple obvious things. GCC added a ton of code to try to check it
through loops, switches, conditionals, and so forth. GCC even tries
to figure out invariants created by constants.
Sometimes it just misses a case. That bit of code is really complex,
I'm not surprised.
The funny thing is that I have actually come to depend on GCC warning
me. Two years ago I would never have coded 'error' the way I did in
that procedure.
I changed the way I code because creating an invariant where all
the flow paths fall through to the same variable assignment at the
end allows GCC to optimize the variable into a short-lived temporary
register that don't have to be reserved in the prior code block, and
also allows GCC to better partition the coding blocks and optimize
other bits of the code better too.
You will even occassionally see me do an unnecessary 'blah = 0' to
force an invariant and allow GCC to better partition the procedure.
Am I nuts? Probably.
-Matt
Matthew Dillon
<dillon at backplane.com>
More information about the Users
mailing list