Skip to content

Commit 4dc5697

Browse files
committed
+1
1 parent b27c916 commit 4dc5697

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

Modules/_struct.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ static PyObject *
265265
unpack_halffloat(const char *p, /* start of 2-byte string */
266266
int le) /* true for little-endian, false for big-endian */
267267
{
268-
double x = PyFloat_Unpack2(p, le);
268+
volatile double x = PyFloat_Unpack2(p, le);
269+
269270
if (x == -1.0 && PyErr_Occurred()) {
270271
return NULL;
271272
}
@@ -291,9 +292,8 @@ static PyObject *
291292
unpack_float(const char *p, /* start of 4-byte string */
292293
int le) /* true for little-endian, false for big-endian */
293294
{
294-
double x;
295+
volatile double x = PyFloat_Unpack4(p, le);
295296

296-
x = PyFloat_Unpack4(p, le);
297297
if (x == -1.0 && PyErr_Occurred())
298298
return NULL;
299299
return PyFloat_FromDouble(x);
@@ -303,9 +303,8 @@ static PyObject *
303303
unpack_double(const char *p, /* start of 8-byte string */
304304
int le) /* true for little-endian, false for big-endian */
305305
{
306-
double x;
306+
volatile double x = PyFloat_Unpack8(p, le);
307307

308-
x = PyFloat_Unpack8(p, le);
309308
if (x == -1.0 && PyErr_Occurred())
310309
return NULL;
311310
return PyFloat_FromDouble(x);
@@ -989,11 +988,14 @@ bu_double(_structmodulestate *state, const char *p, const formatdef *f)
989988
static PyObject *
990989
bu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
991990
{
992-
double x = PyFloat_Unpack4(p, 0);
991+
volatile double x = PyFloat_Unpack4(p, 0);
992+
993993
if (x == -1.0 && PyErr_Occurred()) {
994994
return NULL;
995995
}
996-
double y = PyFloat_Unpack4(p + 4, 0);
996+
997+
volatile double y = PyFloat_Unpack4(p + 4, 0);
998+
997999
if (y == -1.0 && PyErr_Occurred()) {
9981000
return NULL;
9991001
}
@@ -1003,13 +1005,14 @@ bu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
10031005
static PyObject *
10041006
bu_double_complex(_structmodulestate *state, const char *p, const formatdef *f)
10051007
{
1006-
double x, y;
1008+
volatile double x = PyFloat_Unpack8(p, 0);
10071009

1008-
x = PyFloat_Unpack8(p, 0);
10091010
if (x == -1.0 && PyErr_Occurred()) {
10101011
return NULL;
10111012
}
1012-
y = PyFloat_Unpack8(p + 8, 0);
1013+
1014+
volatile double y = PyFloat_Unpack8(p + 8, 0);
1015+
10131016
if (y == -1.0 && PyErr_Occurred()) {
10141017
return NULL;
10151018
}
@@ -1328,11 +1331,14 @@ lu_double(_structmodulestate *state, const char *p, const formatdef *f)
13281331
static PyObject *
13291332
lu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
13301333
{
1331-
double x = PyFloat_Unpack4(p, 1);
1334+
volatile double x = PyFloat_Unpack4(p, 1);
1335+
13321336
if (x == -1.0 && PyErr_Occurred()) {
13331337
return NULL;
13341338
}
1335-
double y = PyFloat_Unpack4(p + 4, 1);
1339+
1340+
volatile double y = PyFloat_Unpack4(p + 4, 1);
1341+
13361342
if (y == -1.0 && PyErr_Occurred()) {
13371343
return NULL;
13381344
}
@@ -1342,13 +1348,14 @@ lu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
13421348
static PyObject *
13431349
lu_double_complex(_structmodulestate *state, const char *p, const formatdef *f)
13441350
{
1345-
double x, y;
1351+
volatile double x = PyFloat_Unpack8(p, 1);
13461352

1347-
x = PyFloat_Unpack8(p, 1);
13481353
if (x == -1.0 && PyErr_Occurred()) {
13491354
return NULL;
13501355
}
1351-
y = PyFloat_Unpack8(p + 8, 1);
1356+
1357+
volatile double y = PyFloat_Unpack8(p + 8, 1);
1358+
13521359
if (y == -1.0 && PyErr_Occurred()) {
13531360
return NULL;
13541361
}

0 commit comments

Comments
 (0)