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

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

 



-----Original Message----- From: Ángel González
Sent: Monday, January 28, 2013 2:17 AM
To: sisyphus1@xxxxxxxxxxxxxxx
Cc: gcc-help@xxxxxxxxxxx
Subject: Re: null argument where non-null required (argument 2)

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.

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



[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