[Cython] Use of long type for intermediate integral variables

Robert Bradshaw robertwb at math.washington.edu
Fri Jul 3 05:50:05 CEST 2015


To clarify, any choice of int64_t + unsigned long will be wrong on one
platform or the others, but getting the wrong sign seems preferable to
getting the wrong number of bits.

On Thu, Jul 2, 2015 at 8:45 PM, Robert Bradshaw
<robertwb at math.washington.edu> wrote:
> I've fixed this particular case by making our integer ranking more
> consistent: signedness is ignored for anything but chars and typedefs
> are always preferred (as a last tiebreaker) over non-typedefs (rather
> than arbitrarily picking the first or second argument).
> https://github.com/cython/cython/commit/61ee8e544bd8802dfc313d832f5da97baf755c3d
>
> I've also upgraded the definition of int64_t to be long long to avoid
> issues with int64_t + unsigned long. There's still an issue of int32_t
> + unsigned int for any platforms where sizeof(int) == 16.
>
>  -Robert
>
> On Thu, Jul 2, 2015 at 1:11 PM, Ian Henriksen
> <insertinterestingnamehere at gmail.com> wrote:
>> On Thu, Jul 2, 2015 at 1:08 PM Robert McGibbon <rmcgibbo at gmail.com> wrote:
>>>
>>> Right, okay. I think I understand.
>>>
>>> -Robert
>>>
>>> On Thu, Jul 2, 2015 at 12:58 AM, Stefan Behnel <stefan_ml at behnel.de>
>>> wrote:
>>>>
>>>> Robert McGibbon schrieb am 02.07.2015 um 09:49:
>>>> >> "libc.stdint.int64_t" is hand-wavingly declared as "long"
>>>> >
>>>> > There are some deeper issues in the rest of your message, but as a
>>>> > preliminary matter, isn't this a clear error for linux-32 and windows?
>>>>
>>>> No, it's not. That's just what Cython sees. The C compiler then sees the
>>>> exact platform specific type. And as the vast amount of Cython code out
>>>> there shows, it's usually not a problem in practice. Cython is designed
>>>> to
>>>> handle most of these "platform specific type" issues at C compile time
>>>> rather than C code generation time. But as your example shows, it can't
>>>> always hide the details entirely. And there can be bugs.
>>>>
>>>> Stefan
>>>>
>>>> _______________________________________________
>>>> cython-devel mailing list
>>>> cython-devel at python.org
>>>> https://mail.python.org/mailman/listinfo/cython-devel
>>>
>>>
>>> _______________________________________________
>>> cython-devel mailing list
>>> cython-devel at python.org
>>> https://mail.python.org/mailman/listinfo/cython-devel
>>
>>
>> This is an interesting discussion. Thanks.
>> For the particular case of int64_t, wouldn't it still be wise to
>> make it a typedef of long long rather than just long so as to consistently
>> get the correct size on platforms where long
>> is only 32 bits?
>> Thanks!
>> -Ian Henriksen
>>
>> _______________________________________________
>> cython-devel mailing list
>> cython-devel at python.org
>> https://mail.python.org/mailman/listinfo/cython-devel
>>


More information about the cython-devel mailing list