D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14341 - [REG 2.067] Crash with -O -release -inline after sort and map!(to!string)
Summary: [REG 2.067] Crash with -O -release -inline after sort and map!(to!string)
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2015-03-25 20:44 UTC by Ivan Kazmenko
Modified: 2015-04-03 17:11 UTC (History)
1 user (show)

See Also:


Attachments
example code (276 bytes, text/plain)
2015-03-25 20:44 UTC, Ivan Kazmenko
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Ivan Kazmenko 2015-03-25 20:44:24 UTC
Created attachment 1498 [details]
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
Comment 1 Vladimir Panteleev 2015-03-26 11:10:57 UTC
Introduced in https://github.com/D-Programming-Language/dmd/pull/4415
Comment 2 Kenji Hara 2015-03-26 14:37:31 UTC
(In reply to Vladimir Panteleev from comment #1)
> Introduced in https://github.com/D-Programming-Language/dmd/pull/4415

This is a dup of issue 14220, but its fix is not yet cherry-picked in 2.067 branch.
Comment 4 Kenji Hara 2015-04-03 17:11:54 UTC
(In reply to Kenji Hara from comment #2)
> (In reply to Vladimir Panteleev from comment #1)
> > Introduced in https://github.com/D-Programming-Language/dmd/pull/4415
> 
> This is a dup of issue 14220, but its fix is not yet cherry-picked in 2.067
> branch.

The 14220 fix was cherry-picked in stable branch.