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.

Author vstinner
Recipients David.Edelsohn, cstratak, fweimer, mark.dickinson, skrah, vstinner
Date 2019-01-17.14:44:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547736254.52.0.711543941858.issue35752@roundup.psfhosted.org>
In-reply-to
Content
The bug occurs when GCC emits a single instruction (stxsspx) for cast + memcpy.

I understand that the struct module is not affected because there is a condition branch (if) between the cast ("float x = ...") and the memcpy().

static int
np_float(char *p, PyObject *v, const formatdef *f)
{
    float x = (float)PyFloat_AsDouble(v);
    if (x == -1 && PyErr_Occurred()) {
        PyErr_SetString(StructError,
                        "required argument is not a float");
        return -1;
    }
    memcpy(p, (char *)&x, sizeof x);
    return 0;
}
History
Date User Action Args
2019-01-17 14:44:16vstinnersetrecipients: + vstinner, mark.dickinson, skrah, fweimer, David.Edelsohn, cstratak
2019-01-17 14:44:14vstinnersetmessageid: <1547736254.52.0.711543941858.issue35752@roundup.psfhosted.org>
2019-01-17 14:44:14vstinnerlinkissue35752 messages
2019-01-17 14:44:14vstinnercreate