[lkml]   [2004]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: GCC 3.4 Heads-up
    Krzysztof Halasa wrote:
    > Bill Davidsen <> writes:
    >>I would probably write
    >> ( a ? b : c ) = d;
    >>instead, having learned C when some compilers parsed ? wrong without
    >>parens. Actually I can't imagine writing that at all, but at least
    >>with parens humans can read it easily. Ugly code.
    >>Your suggestion is not portable, if b or c are declared "register"
    >>there are compilers which will not allow taking the address, and gcc
    >>will give you a warning.
    > One can write as well:
    > if (a)
    > b = d;
    > else
    > c = d;
    > Might be more readable and it is what the compiler does.

    Since that's a matter of taste I can't disagree. The point was that the
    original post used
    *(a ? &b : &c) = d;
    which generates either warnings or errors if b or c is a register
    variable, because you are not allowed to take the address of a register.
    It seems gcc does it anyway by intuiting what you mean, but it's not
    portable in the sense of being error-free code.

    It was a nit, I didn't mean to start a controversy, although if "d" is
    actually a complex expression it is certainly less typing as I showed
    it, and prevents a future maintainer from changing one RHS and not the
    other. That's defensive programming.

    bill davidsen <>
    CTO TMR Associates, Inc
    Doing interesting things with small computers since 1979
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:59    [W:0.022 / U:1.096 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site