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/regression: Bad codegen for inline methods #11636

Closed
jwollen opened this issue Jul 2, 2019 · 1 comment
Closed

Newruntime/regression: Bad codegen for inline methods #11636

jwollen opened this issue Jul 2, 2019 · 1 comment

Comments

@jwollen
Copy link
Contributor

jwollen commented Jul 2, 2019

The following generates invalid C/C++ when imported from another module (the declaring module compiles fine).

This works without newruntime and worked with newruntime in 0.19.4

# moduleA
type Obj* = ref object of RootObj
method test*(self: Obj) {.base, inline.} =
  var s: seq[int]
  s.add(0)

# moduleB
import moduleA

Error:

error: invalid initialization of non-const reference of type 'tySequence_qwqHTkRvwhrRyENtudHQ7g&' from an rvalue of type 'tySequence_qwqHTkRvwhrRyENtudHQ7g*'

The issue is some strange interaction with seq.add where the version of testin the importing module address-of's s erroneously, when a reference is expected:

add_MIAbjRZGBQlNfywJeCn8AQ((&s), ((NI) 0));

The version in the defining module is correct:

add_MIAbjRZGBQlNfywJeCn8AQ(s, ((NI) 0));
@Araq Araq closed this as completed in 476b4ff Jul 3, 2019
narimiran pushed a commit that referenced this issue Jul 8, 2019
(cherry picked from commit 476b4ff)
@Clonkk
Copy link
Contributor

Clonkk commented Jul 21, 2021

I think I have a similar codegen bug with the same error message :

/home/rcaillaud/.cache/nim/mainDapo_r/@mstorage@sstorage@smodels.nim.cpp: In function ‘tySequence__48JTohSgTy339bRxHzUD8KA newSeq_storageZstorageZmodels_1332(NI)’:
/home/rcaillaud/.cache/nim/mainDapo_r/@mstorage@sstorage@smodels.nim.cpp:1383:58: error: invalid initialization of reference of type ‘tySequence__9apztJSmgERYU8fZOjI4pOg&’ from expression of type ‘tySequence__48JTohSgTy339bRxHzUD8KA’
  newSeq_OOZOOZOOZlocalwsZnimfftw51Zfftw51_548(result, len);
                                                          ^
In file included from /home/rcaillaud/.cache/nim/mainDapo_r/@mstorage@sstorage@smodels.nim.cpp:7:0:
/home/rcaillaud/.cache/nim/mainDapo_r/@mstorage@sstorage@smodels.nim.cpp:475:31: note: in passing argument 1 of ‘void newSeq_OOZOOZOOZlocalwsZnimfftw51Zfftw51_548(tySequence__9apztJSmgERYU8fZOjI4pOg&, NI)’
 N_LIB_PRIVATE N_NIMCALL(void, newSeq_OOZOOZOOZlocalwsZnimfftw51Zfftw51_548)(tySequence__9apztJSmgERYU8fZOjI4pOg& s, NI len);
                               ^
/home/rcaillaud/.choosenim/toolchains/nim-#devel/lib/nimbase.h:256:44: note: in definition of macro ‘N_NIMCALL’
 #  define N_NIMCALL(rettype, name) rettype name /* no modifier */
                                            ^~~~

This happens when I try to use --gc:orc on my code base (a few thousands line of code).

I'm trying to work on a minimal reproducible example to investigate (with no success so far). Happens with nim devel f8519657c43f458db9c915cec62c59022041eb05

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

No branches or pull requests

4 participants