summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-30 08:22:16 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-30 08:22:16 (GMT)
commit45cff0c0e6c4a31ed3b5b88ee803320862fbd43a (patch)
tree69dab7ea7f01d3ccf118e1d75edb6c9492b40e02 /Python
parente134a7fe36652434c2ccffc4ebab2ec2031d1505 (diff)
downloadcpython-45cff0c0e6c4a31ed3b5b88ee803320862fbd43a.zip
cpython-45cff0c0e6c4a31ed3b5b88ee803320862fbd43a.tar.gz
cpython-45cff0c0e6c4a31ed3b5b88ee803320862fbd43a.tar.bz2
Issue #22117: Try to fix rounding in conversion from Python double to _PyTime_t
using the C volatile keyword.
Diffstat (limited to 'Python')
-rw-r--r--Python/pytime.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index 98f29ac..5bf8c56 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -207,7 +207,8 @@ int
_PyTime_FromSecondsObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round)
{
if (PyFloat_Check(obj)) {
- double d, err;
+ /* volatile avoids unsafe optimization on float enabled by gcc -O3 */
+ volatile double d, err;
/* convert to a number of nanoseconds */
d = PyFloat_AsDouble(obj);