[Numpy-discussion] RFR: fix signed/unsigned comparison warnings in numpy

Stéfan van der Walt stefan@sun.ac...
Tue Mar 3 07:06:57 CST 2009


2009/3/3 David Cournapeau <david@ar.media.kyoto-u.ac.jp>:
> David Cournapeau wrote:
>> Hi,
>>
>>     A small patch to fix some last warnings (numpy almost builds warning
>> free with -W -Wall -Wextra now). I am not sure about those
>> (signed/unsigned casts are potentially dangerous), so I did not apply
>> them directly. It did help me discovering a bug or two in numpy (fixed
>> in the trunk):
>>
>> http://codereview.appspot.com/24043/
>>
>
> I managed to screw up the link, here is the real one:
>
> http://codereview.appspot.com/24043/show

Looks good!  Thanks, David, for explaining to me why the type cast in

	977 #if @unsigntyp@
	978 if(LONG_MIN < (@ctype@)x && (@ctype@)x < LONG_MAX)
	979 return PyInt_FromLong(x);
	980 #else

has somewhat tricky semantics.  A person is never too old to learn
some more C :-)

Cheers
Stéfan


More information about the Numpy-discussion mailing list