Skip to content

Commit

Permalink
Merge pull request #341 from scala-native/topic/fix-314
Browse files Browse the repository at this point in the history
Fix #314
  • Loading branch information
densh committed Oct 20, 2016
2 parents 3d6211d + d037195 commit 3541b3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ final class Compiler(opts: Opts) {
pass.TryLowering,
pass.AllocLowering,
pass.SizeofLowering,
pass.CopyPropagation)
pass.CopyPropagation,
pass.DeadCodeElimination)

private lazy val (links, assembly): (Seq[Attr.Link], Seq[Defn]) = {
val deps = passCompanions.flatMap(_.depends).distinct
Expand Down
17 changes: 17 additions & 0 deletions unit-tests/src/main/scala/scala/scalanative/issues/_314.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package scala.scalanative.issues

object _314 extends tests.Suite {
test("github.com/scala-native/scala-native/issues/314") {
// Division by zero is undefined behavior in production mode.
// Optimizer can assume it never happens and remove unused result.
assert {
try {
5 / 0
true
} catch {
case _: Throwable =>
false
}
}
}
}

0 comments on commit 3541b3a

Please sign in to comment.