[Issue 16635] New: Alias this for implicit conversion to "ref typeof(this)" causes dmd to run endlessly

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Oct 23 12:02:36 PDT 2016


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

          Issue ID: 16635
           Summary: Alias this for implicit conversion to "ref
                    typeof(this)" causes dmd to run endlessly
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: sprink.noreply at gmail.com

This code causes it to hang indefinitely it seems. I've waited a while and it
still hasn't terminated execution. Some similar code

    struct Vector2
    {
        float x;
        float y;

        alias byRef this;

        ref const(Vector2) byRef() const
        {
            return this;
        }

        Vector2 opBinary(string op : "+")(ref const(Vector2) a) const
        {
            return Vector2(x + a.x, y + a.y);
        }

    }


    void main()
    {
        Vector2 a = Vector2(1, 2);
        Vector2 b = Vector2(3, 4);

        Vector2 c = a + b; // this line causes application to run infinitely

        Vector2 d = a + Vector2(5, 6); // this line seg faults without the
above line

    }

--


More information about the Digitalmars-d-bugs mailing list