[Patches] fix simple 64-bit warnings/errors in signalmodule.c and bufferobject.c

Tim Peters tim_one@email.msn.com
Tue, 6 Jun 2000 17:21:38 -0400


[GregS]
> ...
> #  define SAFE_DOWNCAST(v) ((v) <= INT_MAX ? (int)(v) : abort())

[Trent Mick]
> Sure, but then my compiler will still generate a warning on the
> int downcast that you have there, hence still filling the compile
> output with junk.

Will it really?  Greg has no *implicit* downcasts in that code, and I'm
skeptical that your compiler generates a warning on *explicit* downcasts
(the Win32 MS compiler certainly doesn't).  That would be very unusual.

> ...
> Right. The main "design error" is in Include/object.h:
>
> #define PyObject_VAR_HEAD \
>     PyObject_HEAD \
> 	int ob_size; /* Number of items in variable part */
>
>
> This is 'int' where it should be 'size_t'. We all agree. But this is
> not going to chagne for Python 1.6 (maybe not until 2.0 or 3000).
> Yes, hopefully all these warnings will then go away and clean up the
> Win64 build. Good enough Tim?

Your original example was

>       int size = sizeof(Py_UNICODE);

and changing PyObject_VAR_HEAD will have no effect on that (i.e., that
warning will never go away until that specific line of code is changed).

> Yes, I presume that there is a "right" answer to fix most of
> these warnings.  It is just that the "right" answer is going to
> have to wait for a little bit.

It doesn't "have to".  Python *may* decide to limit sizes to int-sized
things forever (there's not much *practical* need to expand ob_size -- it
would just be "nice" to do so), and so long as it does the code is screwed
up the way it is now.

> Until then the Win64 build is going to have gobs of downcast warnings.

Which is bad.  You didn't create the problem, and nobody is going to force
you to fix it.  Let's just agree that it *is* "a problem".  Then we can make
progress.

it's-not-personal<wink>-ly y'rs  - tim