summaryrefslogtreecommitdiff
path: root/Python/pytime.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-30 10:22:16 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-03-30 10:22:16 +0200
commit3a56f42aa63b0d72187825320cc5ad0bd4d22b9d (patch)
tree7337953e7b15858815383a349a4a03f2fec0eaeb /Python/pytime.c
parent0600ebc4d9a0fbb0f16689fb2c1d6a09482594cc (diff)
downloadcpython-3a56f42aa63b0d72187825320cc5ad0bd4d22b9d.tar.gz
Issue #22117: Try to fix rounding in conversion from Python double to _PyTime_t
using the C volatile keyword.
Diffstat (limited to 'Python/pytime.c')
-rw-r--r--Python/pytime.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index 98f29acc38..5bf8c568e7 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);