On Wed, 12 Mar 2008, Andy Lester wrote:

> 
> On Mar 12, 2008, at 2:33 PM, Andy Dougherty via RT wrote:
> 
> > +#ifdef HASATTRIBUTE_NONNULL_AND_I_REALLY_WANT_TO_USE_IT
> > #  define __attribute__nonnull__(a)         __attribute__((__nonnull__(a)))
> > #endif
> > #ifdef HASATTRIBUTE_NORETURN
> > 
> > and "suddenly" (for some value of suddenly that is more like an hour) 15
> > more tests pass.
> > 
> > Hmm.  Perhaps some of those nonnull's don't belong there.  Alas, I don't
> > have time to go in and hunt them all down.
> 
> 
> The attribute__nonnull tells the compiler that it doesn't have to check for
> null pointers being passed around.  If things are being passed around as null
> that shouldn't be, then the compiler will choke on them because that
> null-checking is optimized away.

Yes.  I know.  That's exactly right.  The problem is twofold:

1.  What if the attribute is simply wrong?  What if a null value is indeed 
ok?  The function may have code to check for a null value and handle it 
correctly, but the compiler has been told it can optimize those checks 
away.  I suspect that's at least partly the case here.

2.  What if the attribute is right and a null isn't supposed to be passed 
in, but a bug elsewhere in the code is sending a null in anyway?  If you 
put debugging code in to catch the null case, the compiler is free to 
optimize it away, and you can't catch the null case.  That's what I was 
running into yesterday with pool in src/headers.c.

Anyway, the cases that are failing with __attribute__nonnull enabled
are:

Failed Test       Stat Wstat Total Fail  List of Failed
-------------------------------------------------------------------------------
t/op/globals.t       2   512     9    2  2 7
t/op/string.t        2   512   160    2  71 73
t/op/trans.t         1   256    22    1  14
t/pmc/coroutine.t    4  1024    11    4  3-6
t/pmc/threads.t      7  1792    20    7  2-3 5 10 12 15-16
t/src/hash.t         1   256    11    1  6
t/src/list.t         1   256     2    1  1
 (7 subtests UNEXPECTEDLY SUCCEEDED), 12 tests and 600 subtests skipped.
Failed 7/259 test scripts. 18/7056 subtests failed.

The t/op/trans.t, t/src/hash.t, and t/src/list.t tests fail with or
without the attribute.

-- 
    Andy Dougherty              [EMAIL PROTECTED]

Reply via email to