Scala Programming Language
  1. Scala Programming Language
  2. SI-7837

quickSort, along with Ordering[K], may result in stackoverflow because the code uses '==' instead of 'equiv'.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.2
    • Fix Version/s: Scala 2.11.0-M8
    • Component/s: Misc Library
    • Labels:
      None
    • Environment:

      Scala 2.10.2

      Description

      The following commands will confirm the failing cases.

      val indices = (0 to 99999).toArray
      val values = Array.fill[Double](100000)(math.random)
      scala.util.Sorting.quickSort[Int](indices)(Ordering.by[Int, Double](values(_))) // Works
      val values2 = Array.fill[Double](100000)(0.0)
      scala.util.Sorting.quickSort[Int](indices)(Ordering.by[Int, Double](values2(_))) // Fails

      In Sorting.scala's code if I change lines 144 and 151 to use equiv, instead of ==, then the problem seems to be resolved.

        Activity

        Hide
        Rex Kerr added a comment -

        Yup, looks like that does it. It's a bit of a trap that everything except == works as expected with an Ordering import. Thanks!

        Show
        Rex Kerr added a comment - Yup, looks like that does it. It's a bit of a trap that everything except == works as expected with an Ordering import. Thanks!

          People

          • Assignee:
            Rex Kerr
            Reporter:
            Sung Hwan Chung
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development