Code to reproduce:
// swig.exe -c++ -java test.i %module Test %inline %{ union //Union1 { struct Struct1 { int i1; }; struct Struct2 { int i2; }; }; %}
Produces the following exception:
0xC0000005: Access violation reading location 0x00000000
Call stack:
msvcrt.dll!_strlen() + 0x26 bytes
swig.exe!0041a392()
Versions:
SWIG Version 3.0.2
Compiled with i586-mingw32msvc-g++ [i586-pc-mingw32msvc]
Configured options: +pcre
Windows 7 Professional SP1 [Version 6.1.7601]
The crash can be prevented by:
- naming the union
- removing the names from the structs
- running without the –c++ option
Reproducible with current git master on Linux.
This patch at least prevents the crash:
However with that applied the example gives some strange warnings about constructors and destructors which aren't explicitly in the example interface file: