D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16635 - Alias this for implicit conversion to "ref const(typeof(this))" causes dmd to segfault
Summary: Alias this for implicit conversion to "ref const(typeof(this))" causes dmd to...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2016-10-23 19:02 UTC by Sprink
Modified: 2021-01-31 09:09 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Sprink 2016-10-23 19:02:36 UTC
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

    }
Comment 1 Dlang Bot 2021-01-27 19:51:35 UTC
@BorisCarvajal created dlang/dmd pull request #12161 "Fix Issue 16635 - Alias this for implicit conversion to "ref typeof(tâ€Ĥ" fixing this issue:

- Fix Issue 16635 - Alias this for implicit conversion to "ref typeof(this)" causes dmd to run endlessly

https://github.com/dlang/dmd/pull/12161
Comment 2 Dlang Bot 2021-01-31 09:09:42 UTC
dlang/dmd pull request #12161 "Fix Issue 16635 - Alias this for implicit conversion to "ref const(typeof(this))" causes dmd to segfault" was merged into master:

- ccdd1ca11baee5174801deb41bdd5f93fbbb55a2 by Boris Carvajal:
  Fix Issue 16635 - Alias this for implicit conversion to "ref typeof(this)" causes dmd to run endlessly

https://github.com/dlang/dmd/pull/12161