Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newruntime: Bad C++ codegen for ref types with destructors #11215

jwollen opened this issue May 9, 2019 · 0 comments


None yet
2 participants
Copy link

commented May 9, 2019

The following generates invalid C++ when compiled with nim cpp --newruntime. It compiles fine in C-mode.

  Foo = object
    bar: ref int

var foo = new Foo

Compiler error:

/home/username/.cache/nim/test_d/stdlib_system.cpp: In function ‘void eqsink__bB9bRZnwQhP0QtnlXujjwSg(tyObject_Foo_QXKNci49c6CMX3pDygFuIRg*&, tyObject_Foo_QXKNci49c6CMX3pDygFuIRg*)’:
/home/username/.cache/nim/test_d/stdlib_system.cpp:4375:39: error: invalid initialization of reference of type ‘tyObject_Foo_QXKNci49c6CMX3pDygFuIRg&’ from expression of type ‘tyObject_Foo_QXKNci49c6CMX3pDygFuIRg*’
 {  eqdestroy__Cap4xY8xy9cNgGn60hfvvfA(dest);
In file included from /home/username/.cache/nim/test8_d/stdlib_system.cpp:9:
/home/username/.cache/nim/test_d/stdlib_system.cpp:411:31: note: in passing argument 1 of ‘void eqdestroy__Cap4xY8xy9cNgGn60hfvvfA(tyObject_Foo_QXKNci49c6CMX3pDygFuIRg&)’
 N_LIB_PRIVATE N_NIMCALL(void, eqdestroy__Cap4xY8xy9cNgGn60hfvvfA)(tyObject_Foo_QXKNci49c6CMX3pDygFuIRg& dest);

A missing deref in destructors and sinks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.