Crystal: Module validation failed: Stored value type does not match pointer operand type!

Created on 20 Jun 2017  路  3Comments  路  Source: crystal-lang/crystal

Module validation failed: Stored value type does not match pointer operand type!
  store i8 %9, i32* %gai_error, !dbg !47
 i32
0x100c2d743: *raise<String>:NoReturn at ??
0x101c0da6b: *Crystal::CodeGenVisitor#finish:Nil at ??
0x101b3903e: *Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::Comp
ilationUnit), Array(String)) | Nil) at ??
0x1023dd764: *Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result at ??
0x1024838a9: *Crystal::Command#run_command<Bool>:Nil at ??
0x100c9b989: *Crystal::Command#run:(Bool | Crystal::Compiler::Result | IO::FileDescriptor | Nil) at ??
0x100c66b9d: main at ??

Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/
crystal-lang/crystal/issues
bug topiccodegen

Most helpful comment

Here is something that fails with a similar error:

lib Library
  struct Struct
    hello : Void*
  end
end

var = 1

Library::Struct.new.hello = pointerof(var)
Module validation failed: Stored value type does not match pointer operand type!
  store i32* %var, i8** %74, !dbg !19
 i8* (Exception)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from __crystal_main
  from main
  from __libc_start_main
  from _start
  from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

I'm not sure if it's the same.

All 3 comments

To reproduce:

lib Lib
  fun blah(error : Int32*) : S

  struct S
    a : Int32
    b : Int32*
    c : Int32
  end
end

result = Lib.blah(out error)

https://carc.in/#/r/285d

Workaround:

lib Lib
  fun blah(error : Pointer(Int32)) : S

  struct S
    a : Int32
    b : Int32*
    c : Int32
  end
end

def f
  err : Int32 = 0 
  result = Lib.blah(pointerof(err))
end

f

https://carc.in/#/r/287g

Here is something that fails with a similar error:

lib Library
  struct Struct
    hello : Void*
  end
end

var = 1

Library::Struct.new.hello = pointerof(var)
Module validation failed: Stored value type does not match pointer operand type!
  store i32* %var, i8** %74, !dbg !19
 i8* (Exception)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from __crystal_main
  from main
  from __libc_start_main
  from _start
  from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

I'm not sure if it's the same.

Was this page helpful?
0 / 5 - 0 ratings