Open swift-ci opened 6 years ago
Attachment: Download
Issue Description:
+++) The following code Crashes with a RELEASE scheme, but is OK on a DEBUG scheme.
+) To reproduce : Run in Xcode Simulator -> Click three times on the RED Box and it crashes.
+) Any of the following three changes to RELEASE scheme seem to fix this crash (and also fix much larger projects that crash with the same fault)
1) Change 'Enable Testability' -> Yes
2) Change 'Compilation Mode' -> Single File
3) Change 'Swift Compiler - Code Generation : Optimization Level' -> Either No optimization or Optimize for Size.
import UIKit var g_but = MY_UIButton(frame: CGRect(x: 100, y: 100,width: 200,height: 200)) let g_false = false let opt_zero : Int? = 0 class EMPTY_CLASS {} let g_empty_arr : [EMPTY_CLASS] = [] class ViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) g_but.backgroundColor = UIColor.red view.addSubview(g_but) g_but.addTarget(g_but,action: #selector(MY_UIButton.touchDown(_:)), for:.touchDown) } } class MY_UIButton : UIButton { @objc func touchDown(_: MY_UIButton?) { if (opt_zero! >= g_empty_arr.count) {} let zero_str = (opt_zero == nil) ? "" : "\(opt_zero!)" if (g_false) { print(zero_str) } if (opt_zero! >= g_empty_arr.count) {} } }
cc @eeckstein
Attachment: Download
Environment
swift 4.1 / Xcode 9.3 / iOS 11.3 / any iDevice Compiled a nMPAdditional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, OptimizedOnly, RunTimeCrash | |Assignee | None | |Priority | Medium | md5: fe8e820e91dd27418a99c6ac1f6ac393Issue Description:
+++) The following code Crashes with a RELEASE scheme, but is OK on a DEBUG scheme.
+) To reproduce : Run in Xcode Simulator -> Click three times on the RED Box and it crashes.
+) Any of the following three changes to RELEASE scheme seem to fix this crash (and also fix much larger projects that crash with the same fault)
1) Change 'Enable Testability' -> Yes
2) Change 'Compilation Mode' -> Single File
3) Change 'Swift Compiler - Code Generation : Optimization Level' -> Either No optimization or Optimize for Size.