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 dmalcolm
Recipients dmalcolm
Date 2010-08-04.23:43:29
SpamBayes Score 1.0808518e-06
Marked as misclassified No
Message-id <1280965412.21.0.0751804906986.issue9518@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-08-04 23:43:32dmalcolmsetrecipients: + dmalcolm
2010-08-04 23:43:32dmalcolmsetmessageid: <1280965412.21.0.0751804906986.issue9518@psf.upfronthosting.co.za>
2010-08-04 23:43:31dmalcolmlinkissue9518 messages
2010-08-04 23:43:29dmalcolmcreate