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

more incorrect code generation by the optimizer (2.11 regression) #9422

Closed
scabug opened this issue Jul 29, 2015 · 3 comments
Closed

more incorrect code generation by the optimizer (2.11 regression) #9422

scabug opened this issue Jul 29, 2015 · 3 comments

Comments

@scabug
Copy link

scabug commented Jul 29, 2015

Here is another case where the optimizer in scala 2.11.x is generating incorrect code:

class Bust(val x: Long) {
  def sameDirection(y: Long): Boolean = 
    (y == 0 || x == 0 || ((y > 0) == (x > 0)))
}

object Bust {
  def main(args: Array[String]) {
    val b = new Bust(1L)
    assert(!b.sameDirection(-1L))
  }
}

This should clearly run without error, but the assertion fails in 2.11.x when -optimise is specified. It works fine if -optimise is left off, and it works fine in scala 2.10.x.

I also tried this with the latest scala nightly build (scala-2.11.8-7492bda-nightly), but it still fails.

@scabug
Copy link
Author

scabug commented Jul 29, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9422?orig=1
Reporter: Jeff Olson (jdolson)
Affected Versions: 2.11.0, 2.11.1, 2.11.2, 2.11.3, 2.11.4, 2.11.5, 2.11.6, 2.11.7

@scabug
Copy link
Author

scabug commented Jul 29, 2015

@retronym said:
Regressed in scala/scala@69109c0. Workaround is to avoid the optimizer, or to use -Yconst-opt:false, which disabled the optimizations introduced in that commit.

% scalac test/files/run/t9422.scala && scala Test // okay
% scalac -Yconst-opt:false -optimize test/files/run/t9422.scala && scala Test // okay

@scabug
Copy link
Author

scabug commented Jul 29, 2015

@retronym said:
Here's a fix: scala/scala#4670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants