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

Add explicit cast in stc/core/stdcpp/array.d#2538

Merged
dlang-bot merged 1 commit intodlang:masterfrom
RazvanN7:patch_19754
Apr 2, 2019
Merged

Add explicit cast in stc/core/stdcpp/array.d#2538
dlang-bot merged 1 commit intodlang:masterfrom
RazvanN7:patch_19754

Conversation

@RazvanN7
Copy link
Contributor

@RazvanN7 RazvanN7 commented Apr 2, 2019

Part 2 for [1] blockade.

[1] dlang/dmd#9505

@RazvanN7 RazvanN7 requested a review from WalterBright as a code owner April 2, 2019 08:50
@dlang-bot
Copy link
Contributor

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 annotated coverage diff directly on GitHub with CodeCov's browser extension
  • 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 fetch digger
dub run digger -- build "master + druntime#2538"

inout(T)* data() inout @safe { static if (N > 0) { return &_M_elems[0]; } else { return null; } }
///
ref inout(T[N]) as_array() inout @trusted { return data()[0 .. N]; }
ref inout(T)[N] as_array() inout @trusted { return cast(inout(T)[N])data()[0 .. N]; }
Copy link
Member

Choose a reason for hiding this comment

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

I feel like that cast should never be necessary. Could you explain why it is ?

Copy link
Contributor Author

@RazvanN7 RazvanN7 Apr 2, 2019

Choose a reason for hiding this comment

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

inout(T[N]) cannot be converted to inout(T)[]. Note that the function was @trusted because the compiler inserted a cast implicitly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you access _M_elems directly, which already has the correct type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted the change to be minimally invasive.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better for it to be correct and avoiding casts.

@dlang-bot dlang-bot merged commit 79a966d into dlang:master Apr 2, 2019
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.

5 participants

Comments