generated abi-mode struct defs breaks unions

Create issue
Issue #357 resolved
Ryan Hileman created an issue

If I run this union through ffi.emit_python_code, the size becomes 32 instead of 16:

struct NVGcolor {
    union {
        float rgba[4];
        struct { float r,g,b,a; };

But the size is right before emitting (all sizes in this output should be 16):

raw ffi: 16 16
generated ffi: 32 16

In the generated ffi code, the union size is 32, suggesting the union fields were combined into a larger incorrect struct. PoC attached, repros in pypy3 and cpython with cffi 1.11.4

Comments (3)

  1. Armin Rigo

    Well spotted. Should be fixed in 6d56592a5c9b.

    It should also work if you use this new revision of cffi to call ffi.emit_python_code, but continue using the older cffi for running your application (like the released cffi for cpython, or the one included with current pypy's).

  2. Log in to comment