boostorg / boostorg/python

Strict aliasing rule violations with python2.7

Abierto
#179 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C++
Estrellas
537
Forks
223
Merge medio
11 h 22 min
PR fusionados (30 d)
2

Descripción

` -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());
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.