A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-August/068417.html below:

[Python-Dev] A cast from Py_ssize_t to long

[Python-Dev] A cast from Py_ssize_t to longThomas Wouters thomas at python.org
Mon Aug 21 16:56:23 CEST 2006
On 8/21/06, Alexander Belopolsky <alexander.belopolsky at gmail.com> wrote:

> There are also cases of implicit casts like this  that were not
> caught so far:
>
> static Py_ssize_t
> mmap_buffer_getreadbuf(mmap_object *self, Py_ssize_t index, const
> void **ptr)
> {
>   ...
>          return self->size;
> }
>
> static Py_ssize_t
> mmap_buffer_getwritebuf(mmap_object *self, Py_ssize_t index, const
> void **ptr)
> {
> ...
>          return self->size;
> }
>
> I don't have any system with sizeof(size_t) != sizeof(long), but it
> maybe worth the effort to review the warnings on such system.


GCC on a LP64 machine does not generate warnings for the above code. It
doesn't have anything to do with 64-bit or 32-bit anyway, since Py_ssize_t
and size_t are supposed to be the same size. They just different in
signedness, and that's the case on any system. Even if those functions were
defined to return longs instead of Py_ssize_t's, GCC wouldn't generate a
warning; it's a valid (implicit) downcast that might lose bits. I believe
there's a Windows compiler that goes warn for such cases, but if so, I'm
sure it generates a whole lot of spurious ones at the moment.

-- 
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060821/f6bef468/attachment.htm 
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4