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-5859] Compiler crash Illegal instruction: 4 #48429

Closed
swift-ci opened this issue Sep 8, 2017 · 3 comments
Closed

[SR-5859] Compiler crash Illegal instruction: 4 #48429

swift-ci opened this issue Sep 8, 2017 · 3 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 regression swift 4.0 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 8, 2017

Previous ID SR-5859
Radar rdar://problem/34334474
Original Reporter tomquist (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Version 9.0 beta 6 (9M214v)
Apple Swift version 4.0 (swiftlang-900.0.63.10 clang-900.0.36)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.0Regression, CompilerCrash, TypeChecker
Assignee tomquist (JIRA)
Priority Medium

md5: 37cda8dd752a0e7e9b8531f08877df9a

Issue Description:

The following code snippet crashes the compiler with "Illegal instruction: 4" in Swift 3 mode and Swift 4 mode:

let a = (0...1).flatMap { _ in return nil }.max() ?? 0

Also adding more type information doesn't fix the crash:

let a = (0...1).flatMap { i in
  if i % 2 == 0 {
    return nil
  } else {
    return i
  }
}.max() ?? 0

Both successfully compile in Swift 3.1

As a workaround, adding type hints fixes the problem:

let a = (0...1).flatMap { i -> Int? in
  if i % 2 == 0 {
    return nil
  } else {
    return i
  }
}.max() ?? 0

Additional info: This bug was introduced in Xcode beta 5. In beta 4 the compiler didn't crash.

@belkadan
Copy link
Contributor

belkadan commented Sep 8, 2017

Looks like a stack overflow, since we get no backtrace even with a debug compiler.

@rudkx
Copy link
Member

rudkx commented Sep 8, 2017

@swift-ci create

@xedin
Copy link
Member

xedin commented Aug 20, 2021

Looks like this issue has been solved at some point. tomquist (JIRA User), please use 5.5 or main branch to verify and close.

@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
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 crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.0 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants