SR-4393 Miscompilation: object modified after being freed (Swift 3.1 regression)
Issue Description:
I've noticed crashes after I upgraded Swift to version 3.1. It happens only when optimization is set to "-O" or "-O whole-module-optimization"
Here is an example code (Example app crashes when following method is called a few times (usually two is enough).
fileprivatefuncfunWithWords(_words: [String]) -> [String] {
varresultArray = [String]()
forindexin0..<words.count {
// This will crashletpre = words[0...index].reduce("", +)
resultArray.append(pre)
// This version is ok// let pre = words[0...index].reduce("", +)// resultArray = resultArray + [pre]// This version is ok too// let pre = words[0...index].joined()// resultArray.append(pre)// This version is ok too// let pre = words[0...index]// let reduced = pre.reduce("", +)// resultArray.append(reduced)
}
returnresultArray
}
Instruments also detects leak in that code. I am attaching screenshot of stack trace from Instruments and Xcode.
I will verify if issue exists on swift-master as well.
The text was updated successfully, but these errors were encountered:
This caused redundant load elimination to remove a load although the value is overwritten in a called function.
Most likely this could only occur if the load address is a block argument.
Attachment: Download
Additional Detail from JIRA
md5: baaae3d56f01cbf35295f4840f3516f5
duplicates:
Issue Description:
I've noticed crashes after I upgraded Swift to version 3.1. It happens only when optimization is set to "-O" or "-O whole-module-optimization"
Here is an example code (Example app crashes when following method is called a few times (usually two is enough).
Instruments also detects leak in that code. I am attaching screenshot of stack trace from Instruments and Xcode.
I will verify if issue exists on swift-master as well.
The text was updated successfully, but these errors were encountered: