[Issue 21888] New: sorting medium sized tuples at compile time not possible

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 3 14:21:31 UTC 2021


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

          Issue ID: 21888
           Summary: sorting medium sized tuples at compile time not
                    possible
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at bernis-buecher.de

While checking https://issues.dlang.org/show_bug.cgi?id=21429 I noticed a
regression: Meanwhile medium sized sorting, like

import std.algorithm;
import std.typecons;

auto foo() {
    enum n = 100;
    auto x = new Tuple!int[n];
    x.sort;
    return x;
}

enum a = foo;

void main() {
}

produces 

/home/D/Repo/dmd/generated/linux/release/64/../../../../../druntime/import/core/lifetime.d(2105):
Error: `memcpy` cannot be interpreted at compile time, because it has no
available source code

with DMD64 D Compiler v2.096.1-242-g9fd50d0be

The error seems to be in std.algorithm.sorting: shortSort. It has specialized
routines for the cases <= 5 and is called for not too large ranges (here up to
256), depending on the size of the elements.

With DMD64 D Compiler v2.090.1 it works.

According to https://run.dlang.io/is/VM5Ufp it was introduced between 2.093.1
and 2.094.1.

--


More information about the Digitalmars-d-bugs mailing list