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]

null argument where non-null required (argument 2)


Hi,

I have MinGW ports of gcc (3.4.5, 4.5.2, 4.6.3, 4.7.0) and, I have some code where I get the warning that forms the subject line of this post.
It's essentially the same warning for all of those versions of gcc, and it needs -Wall to trigger it.


My understanding of that warning is that it's telling me that argument 2 *is* NULL.
Is my understanding correct ?


I have some C code (perl API) and I'm getting that warning even though argument 2 is not NULL ... and I just want to be sure that I'm understanding the message correctly before I chase this up further (on a perl forum).

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



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