Odin
Odin copied to clipboard
cpp panic when comparing struct with it's subtype
A compiler panic when comparing a struct with another that it's using as a subtype.
CODE
Outer :: struct {
using inner: struct {a: int},
b: int,
}
outer: Outer
if outer == outer.inner {
// (ノ ゜Д゜)ノ ︵ ┻━┻
}
OUTPUT
$ odin run .
bug.main
lb_emit_conv: src -> dst
Not Identical struct {a: int} != Outer
Not Identical struct {a: int} != struct {inner: struct {a: int}, b: int}
Not Identical 7460decd7a30 != 7460decd78a0
Not Identical 7460decd7a30 != 7460decd7930
src/llvm_backend_expr.cpp(2324): Panic: Invalid type conversion: 'struct {a: int}' to 'Outer' for procedure 'bug.main'
Illegal instruction (core dumped)
REPORT
Odin: dev-2024-06:cdd90a9a0
OS: Ubuntu 22.04.4 LTS, Linux 6.5.0-35-generic
CPU: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
RAM: 7631 MiB
Backend: LLVM 17.0.6