Hi guys,
Running into an issue with enums and sizes. Might be platform specific (M1 mac), but I don't have access to any other machine right now.
The following fails to compile stating that bar is 8 bytes long, and not 2 as defined (error below):
main :: proc() {
foo :: enum u16 {
Smol,
Enum
}
fmt.printfln("foo is %v bytes long",size_of(foo))
bar :: []u8 { 0, 1 }
fmt.println("bar is %v", transmute(foo)bar) // fails to compile
}
error:
.scratch/scratch.odin(60:31) Error: Cannot cast 'bar' as 'foo' from '[]u8'
fmt.println("bar is %v", foo(bar))
^~^
'[]u8{0, 1}' cannot be represented as the type 'foo'
relevant version info:
odin version
odin version dev-2024-11
clang -v
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: arm64-apple-darwin24.1.0
Thread model: posix
The clang version might be wrong, as I might have used homebrew clang to compile and not apple clang.
Am I just abusing transmutation here or is this actually a bug?