[New-bugs-announce] [issue31373] demoting floating float values to unrepresentable types is undefined behavior

Benjamin Peterson report at bugs.python.org
Wed Sep 6 18:20:42 EDT 2017


New submission from Benjamin Peterson:

According to C99, "When a finite value of real floating type is converted to an integer type other than _Bool, the  fractional  part  is  discarded  (i.e.,  the  value  is  truncated  toward  zero). If the value of the integral part cannot be represented by the integer type,the behavior is undefined." So, e.g., (long)x, where x is a double is in general undefined behavior without a range check. We have several cases in CPython where we need to fix this.

----------
components: Interpreter Core
messages: 301528
nosy: benjamin.peterson
priority: normal
severity: normal
status: open
title: demoting floating float values to unrepresentable types is undefined behavior
type: behavior
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31373>
_______________________________________


More information about the New-bugs-announce mailing list