dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Fix Issue 21613 - DMD crash: copy ctor + templated rvalue ctor

Open RazvanN7 opened this issue 3 years ago • 1 comments

RazvanN7 avatar Feb 18 '22 12:02 RazvanN7

Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
21613 critical DMD crash: copy ctor + templated rvalue ctor

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#13687"

dlang-bot avatar Feb 18 '22 12:02 dlang-bot

@RazvanN7 going to rebase and finish this?

ibuclaw avatar Jan 15 '23 14:01 ibuclaw

@9il it seems that this PR causes a breakage in mir/core. To me it looks like Algebraic ends up defining both a copy constructor and an rvalue constructor. Could you please update the code so that that does not happen anymore?

Edit: Offending code:

    Variant!S a = S();
    auto b = a;

Variant (which is an alias to Algebraic) defines a copy constructor because S defines a copy constructor. Algebraic also defines a templated constructor which is also tried auto b = a is semantically analyzed. This leads to the compiler seeing the possibility of this struct having both an rvalue constructor and a copy constructor.

I think we can get away by simply adding a constraint that excludes the constructor when the RHSTypes matches the instantiation types.

RazvanN7 avatar Jan 16 '23 14:01 RazvanN7

PR: https://github.com/libmir/mir-core/pull/81

RazvanN7 avatar Jan 16 '23 14:01 RazvanN7

@ibuclaw this should be ready to go once https://github.com/libmir/mir-core/pull/81 is in.

RazvanN7 avatar Jan 16 '23 15:01 RazvanN7

@ibuclaw this is ready to go.

RazvanN7 avatar Jan 26 '23 08:01 RazvanN7