Skip to content

[stdlib] Integers are safe #79732

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

Merged
merged 2 commits into from
Mar 3, 2025
Merged

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Mar 2, 2025

The two pointer-sized integer initializers of the form [U]Int.init(bitPattern: (some _Pointer)?) require an unsafe annotation since the implementation of SE-0458 was merged.

Getting integers from pointers isn't unsafe. It's just a way to get an integer. (Mostly a bad way to get an integer.)

This adds @safe to the two initializers in Pointers.swift, then removes many unsafe annotations that become unneeded as a result.

@glessard glessard requested a review from a team as a code owner March 2, 2025 16:29
@glessard
Copy link
Contributor Author

glessard commented Mar 2, 2025

@swift-ci please test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Yes, thank you! This is the safe direction, so @safe is the right annotation.

@glessard glessard enabled auto-merge March 2, 2025 18:14
@glessard glessard merged commit 7899343 into swiftlang:main Mar 3, 2025
4 of 5 checks passed
@glessard glessard deleted the integers-are-safe branch April 25, 2025 18:03
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.

2 participants