offsetof
triggers LLVM assertion failure on StaticArray
#13317
Labels
kind:bug
A bug in the code. Does not apply to documentation, specs, etc.
topic:compiler:codegen
topic:compiler:interpreter
The following triggers an LLVM assertion failure in
LLVMOffsetOfElement
:The relevant code is:
crystal/src/compiler/crystal/semantic/main_visitor.cr
Lines 2607 to 2608 in 5dc9424
It breaks because the LLVM type for
UInt8[4]
is[4 x i8]
, which is an array type, not a struct type. (Crystal::Type#sizeof_type
has no significant effect here.)LLVMOffsetOfElement
only accepts struct types.The same thing happens in the interpreter for
pointerof
, but via a different code path:crystal/src/compiler/crystal/interpreter/compiler.cr
Lines 1528 to 1542 in 5dc9424
The following is an empty prelude reproduction:
Normal codegen doesn't have this issue with
pointerof
, as instance variable addresses there are always obtained at run time viagetelementptr
instructions instead, and no compile-time decision needs to be made.The text was updated successfully, but these errors were encountered: