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

tprocedural_views fails to compile with gcc 14 #1376

Open
alaviss opened this issue Jul 10, 2024 · 1 comment
Open

tprocedural_views fails to compile with gcc 14 #1376

alaviss opened this issue Jul 10, 2024 · 1 comment
Labels
bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler

Comments

@alaviss
Copy link
Contributor

alaviss commented Jul 10, 2024

Example

./koch.py tests --targets:c r tests/lang_experimental/views/tprocedural_views.nim

Actual Output

FAIL: tests/lang_experimental/views/tprocedural_views.nim c        ( 0.18 sec)
Test "tests/lang_experimental/views/tprocedural_views.nim" in category "lang_experimental"
Failure: reNimcCrash
debugInfo:  compiler exit code was 1 but no Error's were found.
$ nimskull/bin/nim c --hints:on -d:testing --clearNimblePath --nimblePath:build/deps/pkgs   --nimCache:nimcache/tests/lang_experimental/views/tprocedural_views.nim_4a8a08f09d37b73795649038408b5f33  tests/lang_experimental/views/tprocedural_views.nim
nimskull/nimcache/tests/lang_experimental/views/tprocedural_views.nim_4a8a08f09d37b73795649038408b5f33/@mtprocedural_views.nim.c: In function ‘NimMainModule’:
nimskull/nimcache/tests/lang_experimental/views/tprocedural_views.nim_4a8a08f09d37b73795649038408b5f33/@mtprocedural_views.nim.c:135:19: error: assignment to ‘NI (**)(NI)’ {aka ‘long int (**)(long int)’} from incompatible pointer type ‘tyProc__AUU7JKzv059aLg8CDEB5NOw’ {aka ‘long int (*)(long int)’} [-Wincompatible-pointer-types]
  135 |         _7.Field0 = _6;
      |                   ^
execution of an external program 'gcc -c  -w -fmax-errors=3   -Inimskull/lib -Inimskull/tests/lang_experimental/views -o nimskull/nimcache/tests/lang_experimental/views/tprocedural_views.nim_4a8a08f09d37b73795649038408b5f33/@mtprocedural_views.nim.c.o nimskull/nimcache/tests/lang_experimental/views/tprocedural_views.nim_4a8a08f09d37b73795649038408b5f33/@mtprocedural_views.nim.c' failed with exit code '1'
@alaviss alaviss added bug Something isn't working compiler/backend Related to backend system of the compiler labels Jul 10, 2024
@zerbina
Copy link
Collaborator

zerbina commented Jul 10, 2024

The problem lies in line 35, with the minimal reproducer being:

type
  Proc = proc (x: int): int {.nimcall.}
  Obj = object
    tup: (lent Proc,)

let
  p = proc(x: int): int = x
  o = Obj(tup: (p,))

As can be seen in the (shortened) --showir:transf output:

0 N:LetSection
  0 N:IdentDefs
    0 N:Sym "o" sk:skLet
    1 N:Empty
    2 N:ObjConstr
      0 N:Sym "Obj" sk:skType
      1 N:ExprColonExpr
        0 N:Sym "tup" sk:skField
            offset:  0
        1 N:TupleConstr
          0 N:Sym "p" sk:skLet # <- this is the important part

The HiddenAddr operation for creating a view of p is missing, meaning that a function pointer is assigned to a location expecting a pointer to a function pointer.

All backends are affected.

@zerbina zerbina added compiler/sem Related to semantic-analysis system of the compiler and removed compiler/backend Related to backend system of the compiler labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler
Projects
None yet
Development

No branches or pull requests

2 participants