Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scope array literals to spec #3442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Oct 19, 2022

Requested here: dlang/dmd#14562 (comment)

@dlang-bot
Copy link
Contributor

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

@ntrel
Copy link
Contributor

ntrel commented Oct 19, 2022

What about when the element type is not plain old data as mentioned in the changelog:
https://github.com/dlang/dmd/pull/14562/files#diff-a773cf7a39af2594f4e2e4f8aa41047d2b2f10a8558a5f0cb1c7d4c86f6d0304R23

@maxhaton
Copy link
Member

What about when the element type is not plain old data as mentioned in the changelog: https://github.com/dlang/dmd/pull/14562/files#diff-a773cf7a39af2594f4e2e4f8aa41047d2b2f10a8558a5f0cb1c7d4c86f6d0304R23

As-if rule may be useful

@pbackus
Copy link
Contributor

pbackus commented Oct 25, 2022

It is worth noting that this change (and others like it) may silently introduce memory corruption into any @trusted code that relied on the old behavior. For example, the following code is memory safe when compiled with DMD 2.100, but will be unsound when compiled with DMD 2.101:

@trusted int[] example()
{
    scope arr = [1, 2, 3];
    return arr;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants