New submission from Dave Malcolm <dmalc...@redhat.com>: Attempting to compile Python 3 extension modules on GCC with "-Wmissing-field-initializers" enabled leads to warnings from the PyModuleDef_HEAD_INIT macro
Seen attempting to build SELinux python bindings against python 3.1 with "-W -Werror", the "-W" implies "-Wmissing-field-initializers": > cc -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn > > -Wmissing-format-attribute -I../include -I/usr/include -D_GNU_SOURCE > > -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.1 -fPIC -DSHARED -c -o > > audit2why.lo audit2why.c > > cc1: warnings being treated as errors > > audit2why.c:439: error: missing initializer > > audit2why.c:439: error: (near initialization for ?moduledef.m_base.m_init¹) > > make: *** [audit2why.lo] Error 1 The PyModuleDef_HEAD_INIT is intended to initialize m_base within a PyModuleDef, but only explicitly initializes the PyObject_HEAD fields: #define PyModuleDef_HEAD_INIT {PyObject_HEAD_INIT(NULL)} typedef struct PyModuleDef_Base { PyObject_HEAD PyObject* (*m_init)(void); Py_ssize_t m_index; PyObject* m_copy; } PyModuleDef_Base; typedef struct PyModuleDef{ PyModuleDef_Base m_base; const char* m_name; const char* m_doc; Py_ssize_t m_size; PyMethodDef *m_methods; inquiry m_reload; traverseproc m_traverse; inquiry m_clear; freefunc m_free; } PyModuleDef; The attached patch extends it to also explicitly zero the other m_base fields. ---------- components: Extension Modules files: py3k-initialize-all-of-m_base.patch keywords: patch, patch messages: 112926 nosy: dmalcolm priority: normal severity: normal stage: patch review status: open title: PyModuleDef_HEAD_INIT does not explicitly initial all fields of m_base type: compile error versions: Python 3.1, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file18396/py3k-initialize-all-of-m_base.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9518> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com