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-10908] Compiler bug when running tests in release mode #53298

Closed
swift-ci opened this issue Jun 10, 2019 · 2 comments
Closed

[SR-10908] Compiler bug when running tests in release mode #53298

swift-ci opened this issue Jun 10, 2019 · 2 comments
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-10908
Radar rdar://problem/51587604
Original Reporter ldewailly (JIRA User)
Type Bug
Status Resolved
Resolution Cannot Reproduce

Attachment: Download

Environment

Xcode 11.0 beta / Swift 5 / macOS Catalina

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

md5: bde70232b32d83f7215c0545e34db4ac

Issue Description:

When running the test in the attached SwiftPM project the following code produces an incorrect result:

func test() {
    let changeStatus = ChangeStatus()
    
    let moreAvailable: Bool
    if case ChangeStatus.Status.noPendingChanges = changeStatus.status {
        moreAvailable = false
    } else {
        moreAvailable = true
    }
    XCTAssertTrue(moreAvailable)
}

By default ChangeStatus.status is set to inconsistent so we expect moreAvailable to be true. But the assertion fails when ran with the following command:

swift test -Xswiftc -enable-testing -c release

The compiler appears to optimize away the entire if/else statement.

In debug mode the test passes.

@bob-wilson
Copy link

I tried to reproduce this with the Xcode 11.0 beta 1 compiler and I did not see the failures.

@bob-wilson
Copy link

Maybe there is something else required to expose this? I was testing the tools and environment specified here. Please double check and if you can consistently reproduce this with the attached test case, try to figure out what else might be different in your environment.

@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. 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