This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: null argument where non-null required (argument 2)
- From: Ángel González <keisial at gmail dot com>
- To: sisyphus1 at optusnet dot com dot au
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 27 Jan 2013 16:17:17 +0100
- Subject: Re: null argument where non-null required (argument 2)
- References: <9DE51EC206FE4CB58CEC496C47DD4C16@OwnerPC311012>
On 27/01/13 04:01, sisyphus1@optusnet.com.au wrote:
> For anyone interested (and in case it might be of relevance), using
> -Wall, I get the warning when I do:
>
> if(strcmp("Math::BigInt", HvNAME(SvSTASH(SvRV(x))))) { .... }
>
> yet, if I break that into 2 lines:
>
> const char * h = HvNAME(SvSTASH(SvRV(x)));
> if(strcmp("Math::BigInt", h)) { .... }
>
> no such warning is emitted.
>
> Also it is already established, prior to the strcmp call, that
> HvNAME(SvSTASH(SvRV(x))) is non-NULL.
>
> And, of course, if argument 2 really was NULL, then the strcmp call
> would crash at runtime - which it doesn't do. (At least, whenever I
> *do* pass a NULL to strcmp, the program crashes at that point during
> execution.)
>
> Main thing for the moment is that I verify that I understand the
> warning correctly.
> (Additional advice/observations are welcome :-)
>
> Cheers,
> Rob
What's the expansion of HvNAME(SvSTASH(SvRV(x))); ? Is it possible that
it expands to a conditional which in one of the branches returns null?
(although never taken in this specific instance)