Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Overflow in 128-bit negative integers #7915

Closed
akadusei opened this issue Jun 22, 2019 · 2 comments · Fixed by #11571
Closed

[Bug] Overflow in 128-bit negative integers #7915

akadusei opened this issue Jun 22, 2019 · 2 comments · Fixed by #11571
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler

Comments

@akadusei
Copy link

This is a bug, according to the compiler:

Code

[playground]

-3_i128

Output

Overflow (OverflowError)
  from ???
  from ???
  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,...

This affects only negative integers.

The bug seems to be a regression introduced in v0.27.2, according to the Crystal playground. It worked fine before.

@akadusei akadusei changed the title Overflow in 128-bit negative integers [Bug] Overflow in 128-bit negative integers Jun 22, 2019
@jhass
Copy link
Member

jhass commented Jun 24, 2019

Trace with symbols:

Arithmetic overflow (OverflowError)
  from __crystal_raise_overflow
  from LLVM::Type#const_int<Int64>:LLVM::Value
  from Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil
  from Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil
  from Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil)
  from Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result
  from Crystal::Command#run:(Bool | Crystal::Compiler::Result | Nil)
  from main

@jhass jhass added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler topic:compiler:parser and removed topic:compiler:parser labels Jun 24, 2019
@jkthorne
Copy link
Contributor

I dont think 128 bit integers are fully implemented yet. I think this is a problem here. Also there is a PR to add 128 bit support. Most of the work was dont in another branch it is just a bit project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Projects
None yet
3 participants