www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14341] New: [REG 2.067] Crash with -O -release -inline after

https://issues.dlang.org/show_bug.cgi?id=14341

          Issue ID: 14341
           Summary: [REG 2.067] Crash with -O -release -inline after sort
                    and map!(to!string)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: regression
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: gassa mail.ru

Created attachment 1498
  --> https://issues.dlang.org/attachment.cgi?id=1498&action=edit
example code

This example, compiled as "dmd -O -release -inline -m64" on Win64, reproducibly
crashes with dmd 2.067.0-b2 and later up to dmd 2.067.0 release, and
reproducibly does not crash with dmd 2.066.1 and earlier.

-----
import std.algorithm, std.conv, std.range, std.stdio;
void main () {
    auto arr = [7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 
1, 1, 2, 2, 8, 5, 8, 8];
    arr.sort !((x, y) => arr.count (x) > arr.count (y) ||
        (arr.count (x) == arr.count (y) && x < y), SwapStrategy.stable)
        .map !(to !(string))
        .join (" ")
        .writeln;
    // prints 1 1 1 1 1 3 3 3 3 3 5 5 5 5 8 8 8 2 2 7 7 0
}
-----

The D.learn discussion resulting in this example:
http://forum.dlang.org/thread/fqbojlyocmsovrpzilhu forum.dlang.org

A somewhat minimized example:

-----
import std.algorithm, std.conv, std.stdio;
void main () {
    auto arr = [1];
    version (S1) sort (arr);
    version (S2) sort !(q{a < b}, SwapStrategy.stable) (arr);
    auto s = map !(to !(string)) (arr);
    if (s.front != "1") {
        writeln ("?");
    }
}
-----

Crashes with either
dmd -O -release -inline -m64 -version=S1
or
dmd -O -release -inline -m64 -version=S2

--
Mar 25 2015