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-9524] Optional flatMap produces differing results between debug and release build in special scenario. #51975

Open
swift-ci opened this issue Dec 15, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-9524
Radar None
Original Reporter derekblr (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode Version 10.1 (10B61)

Swift 4.2

iPhone 8 Simulator (12.1)

OSX 10.13.6 (17G3025)

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

md5: ef7b19558e2ff6cabbb02a9c8210debe

Issue Description:

I've attached a demo project to illustrate the behaviour.

This is what is happening. Consider the following code:

private func foo<T>() -> T? {
    return Optional<Any>.some(Optional<Any>.none as Any) as? T
}


let test: Any? = foo().flatMap { $0 }
if test != nil {
    print("This happens in release")
} else {
    print("This happens in debug")
}

The test variable seems to be nil in debug builds and non-nil in release builds.

@belkadan
Copy link
Contributor

cc @jckarter, @eeckstein. Sounds like the specializer + cast optimizer and the runtime don't agree?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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 optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

2 participants