null argument where non-null required (argument 2)
sisyphus1@optusnet.com.au
sisyphus1@optusnet.com.au
Mon Jan 28 05:55:00 GMT 2013
>-----Original Message-----
>From: Ãngel González
>Sent: Monday, January 28, 2013 2:17 AM
>To: sisyphus1@optusnet.com.au
>Cc: gcc-help@gcc.gnu.org
>Subject: 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.
>
>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)
I would think that is so. (I haven't actually waded through the plethora of
macros, but I would be very surprised if that's not the case.)
In many instances it *does* return null.
Would that be all that's needed to trigger the warning ?
If so, what are my options regarding silencing the warning ?
There's no such warning if I do:
/* x is an int arg passed to the sub - could be any value */
const char *h = x == 0 ? NULL : "Math::BigInt";
if(strcmp("Math::BigInt", h)) { .... }
And there's not even a warning if I do:
const char *h = NULL;
if(strcmp("Math::BigInt", h)) { .... }
Thanks for the reply, Ãngel.
Cheers,
Rob
More information about the Gcc-help
mailing list