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

[SR-6714] Runtime crash when passing an array of mutable pointers to a parameter expecting an array of immutable pointers #49263

Open
hamishknight opened this issue Jan 8, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-6714
Radar rdar://problem/36354660
Original Reporter @hamishknight
Type Bug
Environment

Apple Swift version 4.1-dev (LLVM 5d946db43c, Clang 1212e53405, Swift d726bd8)
Target: x86_64-apple-darwin15.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash, TypeChecker
Assignee None
Priority Medium

md5: 283790d2dde6ebe543f8b4f0a8b2eb46

Issue Description:

The following crashes at runtime:

func foo(_ arr: [UnsafePointer<Int>]) {}

let ptr = UnsafeMutablePointer<Int>.allocate(capacity: 1)
let arr = [ptr]
foo(arr)

with the message "Could not cast value of type 'Swift.UnsafeMutablePointer<Swift.Int>' (0x11338a288) to 'Swift.UnsafePointer<Swift.Int>'".

This is unexpected because there are no force casts in the above code. Either the compiler should reject the passing of an [UnsafeMutablePointer] to a [UnsafePointer] parameter, or the runtime should perform the conversion.

@belkadan
Copy link
Contributor

belkadan commented Jan 8, 2018

@swift-ci create

@tbkka
Copy link
Contributor

tbkka commented Aug 20, 2021

This seems to still be happening with Xcode 12.4, so was unaffected by the dynamic cast overhaul.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants