DragonFly users List (threaded) for 2008-07
DragonFly BSD
DragonFly users List (threaded) for 2008-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Hammer on snapshot cd's


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 15 Jul 2008 11:52:48 -0700 (PDT)

: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@backplane.com>



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]