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-3611] Segfault/assertion for simple tuple collection wrapper #46196

Closed
karwa opened this issue Jan 11, 2017 · 0 comments
Closed

[SR-3611] Segfault/assertion for simple tuple collection wrapper #46196

karwa opened this issue Jan 11, 2017 · 0 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

Comments

@karwa
Copy link
Contributor

karwa commented Jan 11, 2017

Previous ID SR-3611
Radar None
Original Reporter @karwa
Type Bug
Status Resolved
Resolution Duplicate
Environment

Swift 3.0.2
Swift 2302f59

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

md5: 47456f592a60443bbcf0f05b715c187f

duplicates:

  • SR-1795 SILGen crash on overloading functions which take tuple & individual args

Issue Description:

This snippet crashes the REPL both on 3.0.2 and master:

public struct Pair<T>: Collection {
  var _value: (T, T)

  public init(_ first: T, _ second: T) { _value = (first, second) }
  public init(_ value: (T,T))          { _value = value }

  public var count: Index.Stride { return 2 }

  public typealias Index = Int
  public var startIndex: Index { return 0     }
  public var endIndex:   Index { return count }

  public func index(after i: Int) -> Int {
    guard i < endIndex else { preconditionFailure("Cannot increment endIndez") }
    return i + 1
  }

  public subscript(index: Index) -> T {
    get {
      switch index {
        case 0:  return _value.0
        case 1:  return _value.1
        default: fatalError("Invalid index")
      }
    }
    set {
      switch index {
        case 0:  _value.0 = newValue
        case 1:  _value.1 = newValue
        default: fatalError("Invalid index")
      }
    }
  }
}

3.0.2 Segfaults. That's all it tells me.
master fails in an assertion:

Assertion failed: (F->empty() && "already emitted function?!"), function preEmitFunction, file /OpenSource/Apple/swift/lib/SILGen/SILGen.cpp, line 591.
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added crash Bug: A crash, i.e., an abnormal termination of software compiler The Swift compiler in itself labels 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
Projects
None yet
Development

No branches or pull requests

2 participants