scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

dead-code elimination too aggressive: no divide-by-zero error thrown for (1 / x): Unit #8601

Closed scabug closed 10 years ago

scabug commented 10 years ago
% qbin/scala -Ydead-code
Welcome to Scala version 2.12.0-20140517-230840-07399f255c (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0-ea).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class C { def f(x: Int): Unit = 100 / x}
defined class C

scala> :javap C
 ...
{
  public void f(int);
    descriptor: (I)V
    flags: ACC_PUBLIC
    Code:
      stack=0, locals=2, args_size=2
         0: return
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       1     0  this   LC;
            0       1     1     x   I
      LineNumberTable:
        line 7: 0

}

scala> new C().f(0)
 // no exception thrown !
scabug commented 10 years ago

Imported From: https://issues.scala-lang.org/browse/SI-8601?orig=1 Reporter: @retronym Affected Versions: 2.11.0 See #7607

scabug commented 10 years ago

@retronym said: As discovered in Scalaz by the Community Build: https://jenkins-dbuild.typesafe.com:8499/job/Community-2.11.x-manual/23/

scabug commented 10 years ago

@retronym said: https://github.com/scala/scala/pull/3760

scabug commented 10 years ago

@retronym said: https://github.com/scala/scala/pull/3760