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-1980] Emit multiple vtable entries for overrides that change calling convention #44589

Closed
swift-ci opened this issue Jul 3, 2016 · 4 comments
Assignees
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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 3, 2016

Previous ID SR-1980
Radar None
Original Reporter gold_hat (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Swift 2.2 (command line invocation of compiler)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @slavapestov
Priority Medium

md5: c5805c167887e57b9f186f79a3fbcfa9

duplicates:

  • SR-3388 Compiler crash (generics)
  • SR-1529 Compiler crash - overriding an optional property with non-optional can crash the compiler

Issue Description:

The code below generates a type error claiming that the "override" keyword is needed. Once it is added, the type checker will be happy, but the compiler will crash during an optimization phase. I don't believe that the demand for the "override" keyword is warranted since the code will compile and execute fine without it when the argument types are Int? and Int?? instead of Int and Int?.

class BaseClass {
  func f(x: Int) { print("BaseClass.f(Int) [more specific]") }
}

class DerivedClass: BaseClass {
  //override
  func f(x: Int?) { print("DerivedClass.f(Int?) [more general]") }
}

class X: DerivedClass {}

X().f(1)
@belkadan
Copy link
Contributor

belkadan commented Jul 5, 2016

Hm. It's ambiguous whether this is an override or not, but we're definitely supposed to handle it. It's crashing in mandatory inlining, even at -Onone. @eeckstein, who would be good to look at that?

@eeckstein
Copy link
Member

With swift 3 ToT it crashes in SILGen, when it tries to emit the apply for the derived type.

If SILGen emits the call for the base type, then it works (including optimization passes like devirtualization and inlining):

let b : BaseClass = X()
b.f(x: 1)

Joe or John should look at this.

@slavapestov
Copy link
Member

This is an override, but we don't emit the vtable entry properly yet. I'm going to work on this as part of class resilience.

@slavapestov
Copy link
Member

Oops. Re-duping

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants