warning: missing field 'tp_version_tag' initializer [-Wmissing-field-initializers]

Open
#418 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
50/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, python
Domain
backend

Research direction

Start in include/boost/python/opaque_pointer_converter.hpp at the opaque::type_object initializer, and compare its fields with cpython/object.h for Python 3.11. Reproduce the warning with Clang and the listed warning flags, then verify that the initializer no longer emits the missing-field-initializers warning.

Written by the indexing model from the issue text.

Description

Hi,

using Clang 14/15/16 (-Wall -Wpedantic -Wextra) with Boost 1.81.0 and Python 3.11, I get the following warning at

In file included from /my/project/Source.hpp:xx:
In file included from /path/to/boost/1.81.0/include/boost/python.hpp:48:
/path/to/boost/1.81.0/include/boost/python/opaque_pointer_converter.hpp:169:1: warning: missing field 'tp_version_tag' initializer [-Wmissing-field-initializers]

Having a closer look, it seems that when defining a PyTypeObject, at .../include/boost/python/opaque_pointer_converter.hpp, the code isn't considering the last few data members:

// from .../include/python3.11/cpython/object.h
...
struct _typeobject {
...
    PyObject *tp_weaklist;
    destructor tp_del;

    /* Type attribute cache version tag. Added in version 2.6 */
    unsigned int tp_version_tag;

    destructor tp_finalize;
    vectorcallfunc tp_vectorcall;
};
...
// from .../include/boost/python/opaque_pointer_converter.hpp
...
template <class Pointee>
PyTypeObject opaque<Pointee>::type_object =
{
    ...
    0,          /* tp_weaklist */
#if PYTHON_API_VERSION >= 1012
    0           /* tp_del */
#endif
};
...
Dominant language
C++
Stars
537
Forks
223
Avg merge
11h 22m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/python

All issues in boostorg/python

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.