In perl.git, the branch davem/nonnull has been created

<http://perl5.git.perl.org/perl.git/commitdiff/d8b8b7268243f21e9600c2ba53a74710c665698c?hp=0000000000000000000000000000000000000000>

        at  d8b8b7268243f21e9600c2ba53a74710c665698c (commit)

- Log -----------------------------------------------------------------
commit d8b8b7268243f21e9600c2ba53a74710c665698c
Author: David Mitchell <[email protected]>
Date:   Wed Mar 4 15:30:00 2015 +0000

    don't test non-null args
    
    For lots of core functions:
    
    if a function parameter has been declared NN in embed.fnc, don't test for
    nullness at the start of the function, i.e. eliminate code like
    
        if (!foo) ...
    
    On debugging builds the test is redundant, as the PERL_ARGS_ASSERT_FOO
    at the start of the function will already have croaked.
    
    On optimised builds, it will skip the check (and so be slightly faster),
    but if actually passed a null arg, will now crash with a null-deref SEGV
    rather than doing whatever the check used to do (e.g. croak, or silently
    return and let the caller's code logic to go awry). But hopefully  this
    should never happen as such instances will already have been detected on
    debugging builds.
    
    It also has the advantage of shutting up recent clangs which spew forth
    lots of stuff like:
    
        sv.c:6308:10: warning: nonnull parameter 'bigstr' will evaluate to
        'true' on first encounter [-Wpointer-bool-conversion]
            if (!bigstr)
    
    The only exception was in dump.c, where rather than skipping the null
    test, I instead changed the function def in embed.fnc to allow a null arg,
    on the basis that dump functions are often used for debugging (where
    pointers may unexpectedly become NULL) and it's better there to display
    that this item is null than to SEGV.
    
    See the p5p thread starting at [email protected].
-----------------------------------------------------------------------

--
Perl5 Master Repository

Reply via email to