Bugs item #1703952, was opened at 2007-04-19 23:51
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1703952&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.5
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Alexander Belopolsky (belopolsky)
>Assigned to: Thomas Heller (theller)
Summary: ctypes: problem with large integers

Initial Comment:
Python 2.5 (r25:51908, Nov 24 2006, 11:03:50)
[GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2
>>> from ctypes import *
>>> c_int(2**31).value
-2147483648
>>> c_long(2**32-1).value
-1

In a 64-bit build, the situation is even worse:

>>> c_int(int(2**32)).value
0
>>> c_int(2**32).value
0

Another way to see the problem:
>>> c = CDLL(None)
>>> c.printf("%d\n", 2**32)
0
2


----------------------------------------------------------------------

>Comment By: Thomas Heller (theller)
Date: 2007-04-20 20:55

Message:
Logged In: YES 
user_id=11105
Originator: NO

This works as designed.  ctypes intentionally does no overflow checking
when using the c_int, c_uint, and related integer types.  Instead, only the
available bits are used - just as in C.

Closing as invalid (sorry).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1703952&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to