boostorg / boostorg/python

Strict aliasing rule violations with python2.7

Ouverte
#179 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
537
Forks
223
Merge moyen
11 h 22 min
PR mergées (30 j)
2

Description

` -fno-strict-aliasing` must be specified for g++, due to the fact that the Py_* macros rely on UB (access through type punned pointers of incompatible types). This issue is not present in python3.

Reference: http://legacy.python.org/dev/peps/pep-3123/

Some of the warnings produced with g++-7.0.1:
```
gcc.compile.c++ bin.v2/libs/python/build/gcc-gnu-7/release/threadapi-pthread/threading-multi/object/class.o
In file included from /usr/include/python2.7/Python.h:80:0,
from ./boost/python/detail/wrap_python.hpp:151,
from ./boost/python/detail/prefix.hpp:13,
from libs/python/src/object/class.cpp:6:
libs/python/src/object/class.cpp: In function ‘PyObject* boost::python::objects::static_data()’:
/usr/include/python2.7/object.h:115:51: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
^
libs/python/src/object/class.cpp:211:11: note: in expansion of macro ‘Py_TYPE’
Py_TYPE(&static_data_object) = &PyType_Type;
^
libs/python/src/object/class.cpp: In function ‘boost::python::type_handle boost::python::objects::class_metatype()’:
/usr/include/python2.7/object.h:115:51: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
^
libs/python/src/object/class.cpp:319:11: note: in expansion of macro ‘Py_TYPE’
Py_TYPE(&class_metatype_object) = &PyType_Type;
^
libs/python/src/object/class.cpp: In function ‘boost::python::type_handle boost::python::objects::class_type()’:
/usr/include/python2.7/object.h:115:51: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
^
libs/python/src/object/class.cpp:473:11: note: in expansion of macro ‘Py_TYPE’
Py_TYPE(&class_type_object) = incref(class_metatype().get());
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.