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]: Quantification over all char values implemented incorrectly in Java runtime #3001

Closed
robin-aws opened this issue Nov 5, 2022 · 0 comments · Fixed by #3016
Closed
Assignees
Labels
during 4: bad execution of correct program A bug in the Dafny compiler that causes a correct Dafny program to execute incorrectly lang: java Dafny's Java transpiler and its runtime part: runtime Happens in Dafny's runtime (Add a `lang` tag if relevant)

Comments

@robin-aws
Copy link
Member

Dafny version

3.9.1

Code to produce this issue

method Main() {
  var allChars := set c: char | true;
  var allUTF16CodeUnits := set i: int | 0 <= i < 0x10000 :: i as char;
  assert forall c: char :: 0 <= c as int < 0x10000;
  assert allChars == allUTF16CodeUnits;
  
  if allChars != allUTF16CodeUnits {
    print 1/0;
  }
}

Command to run and results

dafny run Scratch.dfy -t:java

What happened?

Exception in thread "main" java.lang.ArithmeticException: BigInteger divide by zero

Root cause is a typo in Helpers.AllChars() (0x1000 instead of 0x1_0000).

Will fix in the upcoming --unicode-char implementation PR, just wanted to track the soundness bug.

Loving the new issue template! :)

What type of Operating System are you seeing the problem on?

Mac

@robin-aws robin-aws added lang: java Dafny's Java transpiler and its runtime part: runtime Happens in Dafny's runtime (Add a `lang` tag if relevant) during 4: bad execution of correct program A bug in the Dafny compiler that causes a correct Dafny program to execute incorrectly labels Nov 5, 2022
@robin-aws robin-aws self-assigned this Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
during 4: bad execution of correct program A bug in the Dafny compiler that causes a correct Dafny program to execute incorrectly lang: java Dafny's Java transpiler and its runtime part: runtime Happens in Dafny's runtime (Add a `lang` tag if relevant)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant