[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] [BUG] 64-bit int/long confusion



A nest of bugs was uncovered by a number of PyWeek #5 entries:

 http://www.pyweek.org/d/1250

The following short program demonstrates one of the bugs::

 import pygame
 s = pygame.Surface((10, 10))
 print s.get_rect(bottom=100)

Result printed is <rect(0, 0, 10, 10)> instead of <rect(0, 90, 10, 10)>. The problem is due to incorrect variable typing when compiled with 64-bit longs and pointers. This set of warnings printed by gcc should cover everything (the specific example above is caused by surface.c:1357)::

src/rect.c:1038: warning: initialization from incompatible pointer type
src/rect.c:1039: warning: initialization from incompatible pointer type
src/rect.c:1040: warning: initialization from incompatible pointer type
src/surface.c: In function `surf_get_rect':
src/surface.c:1357: warning: passing arg 2 of `PyDict_Next' from incompatible pointer type
src/surface.c: In function `surface_init':
src/surface.c:1907: warning: cast from pointer to integer of different size
src/surface.c:1909: warning: cast from pointer to integer of different size
src/surface.c:1911: warning: cast from pointer to integer of different size
src/surface.c:1914: warning: cast from pointer to integer of different size
src/surface.c:1919: warning: cast from pointer to integer of different size
src/surface.c:1929: warning: cast from pointer to integer of different size
src/surface.c:1949: warning: cast from pointer to integer of different size
src/time.c: In function `timer_callback':
src/time.c:37: warning: cast from pointer to integer of different size
src/time.c: In function `time_set_timer':
src/time.c:220: warning: cast to pointer from integer of different size
src/image.c: In function `image_tostring':
src/image.c:324: warning: passing arg 3 of `PyString_AsStringAndSize' from incompatible pointer type src/image.c:337: warning: passing arg 3 of `PyString_AsStringAndSize' from incompatible pointer type src/image.c:413: warning: passing arg 3 of `PyString_AsStringAndSize' from incompatible pointer type src/image.c:493: warning: passing arg 3 of `PyString_AsStringAndSize' from incompatible pointer type
src/image.c: In function `image_fromstring':
src/image.c:617: warning: passing arg 3 of `PyString_AsStringAndSize' from incompatible pointer type
src/image.c: In function `image_frombuffer':
src/image.c:742: warning: passing arg 3 of `PyObject_AsCharBuffer' from incompatible pointer type


Alex.