You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am storing a level id union into a globally loaded level, but when reloading the level (loading the current level's id), I found this bug...
Odin: dev-2025-05:4d7876bdb
OS: Windows 10 Professional (version: 22H2), build 19045.5737
CPU: Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
RAM: 16311 MiB
Backend: LLVM 20.1.0
Expected Behavior
Non-pointer parameters should always act as if they are copied by value, not reference.
Failure Information
It seems like the "odin" calling convention is optimizing large (over 128 bit) union values to pointers, even when the value is modified in the procedure.
Here is a simple test case, that additionally shows that this issue is not present in "cdecl" procedures:
package main
import"base:runtime"import"core:fmt"
global : UnionType
UnionType :: union {
i128,
}
main :: proc() {
global = 42set_global_cdecl(global, context)
set_global_odin(global)
}
set_global_cdecl :: proc"cdecl" (new_value : UnionType, ctx : runtime.Context) {
context = ctx
fmt.println("C BEFORE:", new_value) // C BEFORE: 42
global = {}
fmt.println("C AFTER:", new_value) // C AFTER: 42
global = new_value
}
set_global_odin :: proc"odin" (new_value : UnionType) {
fmt.println("O BEFORE:", new_value) // O BEFORE: 42
global = {}
fmt.println("O AFTER:", new_value) // O AFTER: nil
global = new_value
}
The text was updated successfully, but these errors were encountered:
Context
I am storing a level id union into a globally loaded level, but when reloading the level (loading the current level's id), I found this bug...
Odin: dev-2025-05:4d7876bdb
OS: Windows 10 Professional (version: 22H2), build 19045.5737
CPU: Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
RAM: 16311 MiB
Backend: LLVM 20.1.0
Expected Behavior
Non-pointer parameters should always act as if they are copied by value, not reference.
Failure Information
It seems like the "odin" calling convention is optimizing large (over 128 bit) union values to pointers, even when the value is modified in the procedure.
Here is a simple test case, that additionally shows that this issue is not present in "cdecl" procedures:
The text was updated successfully, but these errors were encountered: