boostorg / boostorg/python

Strict aliasing rule violations with python2.7

Offen
#179 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
537
Forks
223
Ø Merge
11 Std. 22 Min.
Gemergte PRs (30 T.)
2

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.