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

[6.0] Suppress pointer conversion warnings for BitwiseCopyable elements. #73726

Merged
merged 1 commit into from
May 23, 2024

Conversation

atrick
Copy link
Member

@atrick atrick commented May 17, 2024

Now that BitwiseCopyable is accepted, it should work as the recommended workaround for unsafe pointer conversion warnings:

Forming 'UnsafeMutableRawPointer' to a variable of type 'S'; this is likely incorrect because 'S' may contain an object reference.

The check for trivial element types is in SILGenExpr, diagnoseImplicitRawConversion. For now, we can hack SILGenExpr to specifically disable the warning for BitwiseCopyable, just as it was done for FixedWidthInteger in prior releases.

Fixes rdar://128229439 (Conversion from BitwiseCopyable to UnsafeRawPointer should not warn.)

(cherry picked from commit 6bd0ef0)

--- CCC ---

Explanation: Suppress pointer conversion warnings for BitwiseCopyable elements.

Scope: Many Swift devs have complained about this warning and asked for a workaround. BitwiseCopyable was always the recommeded workaround, but only recently landed. Now they can deploy this workaround when building against 6.0.

Radar/SR Issue: rdar://128229439 (Conversion from BitwiseCopyable to UnsafeRawPointer should not warn.)

Original PR: #73687

Risk: None. This disables a warning for new adopters of BitwiseCopyable.

Testing: Dozens of unit tests.

Reviewer: @nate-chandler

Now that BitwiseCopyable is accepted, it should work as the recommended workaround for unsafe pointer conversion warnings:

Forming 'UnsafeMutableRawPointer' to a variable of type 'S'; this is likely incorrect because 'S' may contain an object reference.

The check for trivial element types is in SILGenExpr, diagnoseImplicitRawConversion. For now, we can hack SILGenExpr to specifically disable the warning for BitwiseCopyable, just as it was done for FixedWidthInteger in prior releases.

Fixes rdar://128229439 (Conversion from BitwiseCopyable to UnsafeRawPointer should not warn.)

(cherry picked from commit 6bd0ef0)
@atrick atrick requested a review from a team as a code owner May 17, 2024 23:06
@atrick
Copy link
Member Author

atrick commented May 17, 2024

@swift-ci test

@atrick atrick requested a review from tbkka May 17, 2024 23:06
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels May 18, 2024
@atrick
Copy link
Member Author

atrick commented May 20, 2024

@swift-ci test

@atrick
Copy link
Member Author

atrick commented May 22, 2024

@swift-ci smoke test

@atrick
Copy link
Member Author

atrick commented May 22, 2024

@swift-ci test

@atrick atrick merged commit bb9c038 into apple:release/6.0 May 23, 2024
5 checks passed
@atrick atrick deleted the 60-fix-bitwise-pointer-warning branch May 23, 2024 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants