This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]