Nicholas Clark
2008-12-31 18:08:36 UTC
One trap: If the gcc attribute_nonnull is still used for these same
functions, gcc can optimize away the NULL checks, rendering them
useless.functions, gcc can optimize away the NULL checks, rendering them
I'd recommend also getting rid of the attribute_nonnull gcc
checking. Ihave posted about this at length in previous RT tickets, if you
need morebackground.
Ok, I've gone and read through RT #49316 and RT #50684. It sounds anawful lot like attribute_nonnull is an optimization, not a constraint as
I had originally thought. Therefore it's working against us, not
with us.
I'm pretty sure assert() is a C library function.
I think it's a C #define'd macro, not a function, which is not expanded
if you set the right debug #define
(don't know details by heart).
rid of attribute_nonnull (for now).
then gcc doesn't short circuit the assertions, so they fire off if they are
violated, keeping the attribute_nonnulls honest.
Then if you build with the optimiser, and the right macro to stop assertions
being expanded at all (-DNDEBUG, IIRC), it's as if the assertions aren't there,
and gcc may well take advantage of the (honest, validated) attribute_nonnulls
to optimiser better.
Well, it all works as long as the test coverage is good enough.
We've not had any further problems with them in Perl 5 since I added assertions
and fixed all the errors they found.
Nicholas Clark