-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
SILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfoptimized onlyFlag: An issue whose reproduction requires optimized compilationFlag: An issue whose reproduction requires optimized compilation
Description
Previous ID | SR-13449 |
Radar | rdar://problem/68170038 |
Original Reporter | @lxbndr |
Type | Bug |
Status | Closed |
Resolution | Done |
Environment
Swift version 5.3-dev (LLVM 36f7fac60d2e676, Swift a5ca83a8b2d499f)
Target: x86_64-unknown-windows-msvc
Additional Detail from JIRA
Votes | 1 |
Component/s | Compiler |
Labels | Bug, OptimizedOnly, Optimizer |
Assignee | None |
Priority | Medium |
md5: 205e769ae641e22368ccb8ccbb625245
blocks:
- TF-1314 Networking timeout
Issue Description:
Under specific conditions binary built with optimizations would call wrong method inside a class. This is the reason why network requests are not working in swift-corelibs-foundation
at the moment.
Sample code have to be split in two sources, otherwise the issue is not reproduced.
// Grandchild.swift
class Grandchild: Child {}
// main.swift
class Root {}
class Child: Root {
func doSomething() {
print("-- \(type(of: self)) - \(#function) - will call doHomework()")
doHomework()
print("-- \(type(of: self)) - \(#function) - did call doHomework()")
}
private func eatPopcorn() {
print("-- \(type(of: self)) - \(#function)")
}
func playGames() {
print("-- \(type(of: self)) - \(#function) - SHOULD NOT HAPPEN")
eatPopcorn()
}
func doHomework() {
print("-- \(type(of: self)) - \(#function)")
}
}
Grandchild().doSomething()
Expected output:
-- Grandchild - doSomething() - will call doHomework()
-- Grandchild - doHomework()
-- Grandchild - doSomething() - did call doHomework()
Actual output:
-- Grandchild - doSomething() - will call doHomework()
-- Grandchild - playGames() - SHOULD NOT HAPPEN
-- Grandchild - eatPopcorn()
-- Grandchild - doSomething() - did call doHomework()
Metadata
Metadata
Assignees
Labels
SILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfoptimized onlyFlag: An issue whose reproduction requires optimized compilationFlag: An issue whose reproduction requires optimized compilation