Re: null argument where non-null required (argument 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27/01/13 04:01, sisyphus1@xxxxxxxxxxxxxxx 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)




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux