Skip to content

Bad codegen with {.exportc.} variant member #4152

Open
@yglukhov

Description

type Foo* = object
    case smth: bool
    of true:
        refval {.exportc.}: int
    else: nil

var v: Foo
v.smth = true
v.refval = 5 # Bad codegen!
Hint: system [Processing]
Hint: test [Processing]
CC: test
CC: stdlib_system
Error: execution of an external compiler program 'clang -c  -w  -I/Users/yglukhov/Projects/nim/lib -o /Users/yglukhov/nimcache/test.o /Users/yglukhov/nimcache/test.c' failed with exit code: 256

/Users/yglukhov/nimcache/test.c:149:21: error: no member named 'refval' in 'struct Foo95004'
        v_95007_2076107616.refval = ((NI) 5);
        ~~~~~~~~~~~~~~~~~~ ^
/Users/yglukhov/nimcache/test.c:166:20: error: no member named 'refval' in 'Foo95004'
TMP139[1].offset = offsetof(Foo95004, refval);
                   ^                  ~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/include/stddef.h:120:24: note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
2 errors generated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions