This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Undefined behaviour in _PyFloat_Pack4
Type: behavior Stage: needs patch
Components: Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: mark.dickinson
Priority: normal Keywords:

Created on 2010-07-07 16:42 by mark.dickinson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg109483 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-07-07 16:42
_PyFloat_Pack4 does a double-to-float cast, without first checking that the value being converted is within the range of a float.  According to C99 6.3.1.5p2, this results in undefined behaviour.  It should be fixed (probably via comparison with FLT_MAX before casting.)

np_float in the struct module also has this problem.
msg112866 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-08-04 19:09
Closing this as not worth worrying about.  This *is* undefined behaviour, but it really doesn't seem to be a problem in practice.  (It might have been better for the C standard to describe this as merely implementation-defined.)
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53436
2010-08-04 19:09:29mark.dickinsonsetstatus: open -> closed
resolution: wont fix
2010-08-04 19:09:05mark.dickinsonsetmessages: + msg112866
2010-07-07 16:42:23mark.dickinsoncreate