Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Fix _d_arrayctor to allow @nogc#3582

Merged
RazvanN7 merged 1 commit intodlang:masterfrom
teodutu:fix-_d_arrayctor
Oct 8, 2021
Merged

Fix _d_arrayctor to allow @nogc#3582
RazvanN7 merged 1 commit intodlang:masterfrom
teodutu:fix-_d_arrayctor

Conversation

@teodutu
Copy link
Copy Markdown
Member

@teodutu teodutu commented Oct 7, 2021

This PR fixes the _d_arrayctor template, which is to be used by dmd instead of the old hook, as implemented in this PR: dlang/dmd#13116

The previous implementation used enforceRawArraysConformable, which prevented it from being called by @nogc functions. This resulted in some dmd unittests failing in the PR above.

The previous implementation used `enforceRawArraysConformable`, which
prevented it from being called by @nogc functions.

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @teodutu! 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

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

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 "master + druntime#3582"

void[] vFrom = (cast(void*)from.ptr)[0..from.length];
void[] vTo = (cast(void*)to.ptr)[0..to.length];
enforceRawArraysConformable("initialization", element_size, vFrom, vTo, false);
assert(vFrom.length == vTo.length, "Array lengths don't match");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's quite unfortunate that we have to use such a bad error message, but at this point I don't really see another alternative.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use a similar hack to the one used to make Exceptions @nogc.

The idea behind the hack is to statically allocate on the TLS a predefined _store and use that to hold the Exception object. In our case, we would use the TLS _store to hold the error message.

@RazvanN7 RazvanN7 merged commit 5693fdf into dlang:master Oct 8, 2021
@teodutu teodutu deleted the fix-_d_arrayctor branch October 8, 2021 15:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants