[Issue 22446] New: isInputRange fails to recognize range if element type is nested struct that has a copy ctor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 28 05:14:26 UTC 2021


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

          Issue ID: 22446
           Summary: isInputRange fails to recognize range if element type
                    is nested struct that has a copy ctor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: stanislav.blinov at gmail.com

import std.range;

void main() {
    struct S {
        // comment this ctor to make the issue disappear
        this(return ref scope const S) {}

        void remainNestedEvenIfCtorAboveIsCommented() {}
    }

    static assert(__traits(isNested, S));   // passes

    static assert(isInputRange!(S[]));      // fails
}

---

Removing the copy ctor makes the check pass, so this might be a dmd issue?..

It would seem that the problematic check in isInputRange is the

is(typeof((return ref R r) => r.front))

which triggers the infamous "cannot access frame pointer", but not when the
copy ctor is not present.

--


More information about the Digitalmars-d-bugs mailing list