boostorg / boostorg/python

no_init/compiler-generated constructor on struct causes segfault

Offen
#120 5 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

If I compile the following extension, then as soon as I load it into a Python script I get a `Segmentation fault (core dumped)`. The cause seems to be the `no_init` on class Bar. I'd be grateful for any help.

```
#include

using namespace std;
using namespace boost::python;

struct Bar {
string x;
};

BOOST_PYTHON_MODULE (libtest_python) {
class_("Bar", no_init)
.def_readonly("x", &Bar::x);
}
```

The reason for using the `no_init` is that `init()` doesn't pick up the compiler-generated constructor. If I write my own constructor and use `init()`, it loads fine. (But I'm wrapping code that I can't modify, and the struct constructor is compiler generated.)

Using Windows/Cygwin, gcc 5.4.0, python 2.7 and Boost 1.60.0, all installed via Cygwin rather than windows.

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.