Build never ends if `-O` or `-Owholemodule` in Xcode 9
| Originator: | kishikawakatsumi | ||
| Number: | rdar://34597258 | Date Originated: | September 23 2017 |
| Status: | Open | Resolved: | |
| Product: | Xcode | Product Version: | Version 9.0 (9A235) |
| Classification: | Reproducible: | Always |
Summary:
Steps to Reproduce:
1. Create a new Swift project.
2. Set `SWIFT_OPTIMIZATION_LEVEL = -O` in build setting or select Release build configuration in schema
3. Add a new file and paste the following code
public class A {
public class func f() {
B.f()
}
}
class B {
private class C {
var this: C? = nil
lazy var number: Int = {
var local: C? = self
let count = 0
while let temp = local?.this {
local = temp
}
return count
}()
func f() -> C {
if number == 0 {
return self
}
print(number)
return self
}
}
class func f() {
let _ = C().f()
}
}
4. Build
Expected Results:
Build finishes
Actual Results:
Build never ends, swift process CPU usage reaches 100%
Version/Build:
Xcode Version 9.0 (9A235)
macOS Sierra 10.12.6
Configuration:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!