Odin
Odin copied to clipboard
Global assignment not copying other global
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
- Operating System & Odin Version: Odin: dev-2022-08:d570e491 OS: Windows 11 Home Basic (version: 21H2), build 22000.856 CPU: 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz RAM: 32602 MiB
Expected Behavior
Global assignment copy's the values of other global.
Current Behavior
The global is assigned the zero value if the global it is trying to copy doesn't have all literal values.
Steps to Reproduce
package example
import "core:fmt"
import "core:strings"
import "core:os"
Sorter :: struct{
img_path: string,
threads: int,
tasks: int,
threshold: int,
}
g_sorter := Sorter {
img_path = strings.clone("jellyfish.png", os.heap_allocator()),
/*img_path = "jellyfish.png",*/
threads = 4,
tasks = 4,
threshold = 100,
}
g_sorter_swap := g_sorter
main :: proc() {
fmt.println(g_sorter)
fmt.println(g_sorter_swap)
}
Output:
Sorter{img_path = "jellyfish.png", threads = 4, tasks = 4, threshold = 100}
Sorter{img_path = "", threads = 0, tasks = 0, threshold = 0}
However, plain old data works just fine when using a string literal for img_path. Then the output is as expected.