lkml.org 
[lkml]   [2009]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] BUILD_BUG_ON: make it handle more cases
    From
    Date
    On Tue, 2009-10-20 at 14:15 +1030, Rusty Russell wrote:
    > BUILD_BUG_ON used to use the optimizer to do code elimination or fail
    > at link time; it was changed to first the size of a negative array (a
    > nicer compile time error), then (in
    > 8c87df457cb58fe75b9b893007917cf8095660a0) to a bitfield.
    >
    > bitfields: needs a literal constant at parse time, and can't be put under
    > "if (__builtin_constant_p(x))" for example.
    > negative array: can handle anything, but if the compiler can't tell it's
    > a constant, silently has no effect.
    > link time: breaks link if the compiler can't determine the value, but the
    > linker output is not usually as informative as a compiler error.
    >
    > If we use the negative-array-size method *and* the link time trick,
    > we get the ability to use BUILD_BUG_ON() under __builtin_constant_p()
    > branches, and maximal ability for the compiler to detect errors at
    > build time.
    >
    > Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

    Thanks Rusty, this indeed fixes the problem.

    Acked-by: Hollis Blanchard <hollisb@us.ibm.com>

    --
    Hollis Blanchard
    IBM Linux Technology Center



    \
     
     \ /
      Last update: 2009-10-22 23:07    [W:0.021 / U:31.468 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site