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-863] NSURL(fileURLWithPath: "") results in EXC_BAD_ACCESS #43475

Closed
jepers opened this issue Mar 3, 2016 · 5 comments
Closed

[SR-863] NSURL(fileURLWithPath: "") results in EXC_BAD_ACCESS #43475

jepers opened this issue Mar 3, 2016 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay

Comments

@jepers
Copy link

jepers commented Mar 3, 2016

Previous ID SR-863
Radar rdar://problem/25118040
Original Reporter @jepers
Type Bug
Status Closed
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, SDKOverlay
Assignee None
Priority Medium

md5: 8fdf6b6ac74bd81548ecf57d2adf6392

Issue Description:

This code compiles and produces an EXC_BAD_ACCESS when run:

let url = NSURL(fileURLWithPath: "")
print(url)

Using Xcode 7.3 beta (7D152p)

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 3, 2016

According to the documentation of this method:

Return Value: An NSURL object initialized with path, or nil if path is zero-length.

But the method is marked as returning a non-optional.

And you can verify that this is what's going on by using the code

let url: NSURL? = NSURL(fileURLWithPath: "")
print(url)

(this trick of explicitly typing the variable as an optional lets you handle any case where an Obj-C method is marked as returning a non-optional value but is actually returning nil).

@belkadan
Copy link
Contributor

belkadan commented Mar 8, 2016

Given Kevin's diagnosis, this isn't a Swift issue; it should be filed against Apple Foundation in Radar.

@jepers
Copy link
Author

jepers commented Mar 8, 2016

Please forgive my ignorance, but I couldn't find any category resembling Apple Foundation in bugreport.apple.com. So I'll leave it to anyone who knows how to (file it against Apple Foundation in Radar).

@lilyball
Copy link
Mannequin

lilyball mannequin commented Mar 8, 2016

@jepers File it against either "iOS SDK" or "OS X SDK".

@jepers
Copy link
Author

jepers commented Mar 11, 2016

OK, done: 25118040

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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. SDKOverlay
Projects
None yet
Development

No branches or pull requests

2 participants