[Issue 20309] New: Passing alias this with function returning chain to tempCString hangs up the program

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 21 10:55:33 UTC 2019


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

          Issue ID: 20309
           Summary: Passing alias this with function returning chain to
                    tempCString hangs up the program
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: d.bugs at webfreak.org

The following minimal test case will result in a binary which hangs up:

import std.range : chain;
import std.internal.cstring : tempCString;

struct Test {
    auto filename() const { return chain("a", "b"); }
    alias filename this;
}

void main() {
    auto name = Test();
    auto namez = name.tempCString!char();
    // should return fine or crash if doesn't exist, but not hang
}

See https://run.dlang.io/is/8AlJO5

This is a bug because with `name.filename.tempCString!char()` it works fine, so
it has an issue with the alias this on that range.

This causes calls to the std.file functions like isFile or getAttributes to
hang up if called with a struct like this.

This only happens when it is indirected via an alias this on the argument which
is passed.

Another test to test it with public APIs: `std.file.getAttributes(Test())`

--


More information about the Digitalmars-d-bugs mailing list