Segmentation Fault with Optimized Build (Swift)
Originator: | pavol.vaskovic | ||
Number: | rdar://19320793 | Date Originated: | |
Status: | Closed | Resolved: | Fixed |
Product: | Developer Tools | Product Version: | Xcode 6.2 Beta (6C86e) |
Classification: | Reproducible: |
Summary: The attached testcase crashes with Segmentation fault: 11, when running the optimized build. Debug build works fine. Steps to Reproduce: Compile and run the attached testcase with optimizations. Expected Results: Code runs without segmentation fault. Actual Results: Segmentation fault: 11 Version: Xcode 6.2 Beta (6C86e), as well as 6.1 release. Mac OS X 10.10.1 (14B25) Notes: Configuration: Happens in optimized build. Attachments: 'main.swift' import Foundation let iterations = 100 func takeWhile<S : SequenceType>(includeElement: S.Generator.Element -> Bool, source: S) -> GeneratorOf<S.Generator.Element> { var g = source.generate() return GeneratorOf { if let e = g.next() { return includeElement(e) ? e : .None } else { return .None } } } func iterate<A>(f: A -> A, x0: A) -> GeneratorOf<A> { var x = x0 return GeneratorOf { let previous = x x = f(x) return previous } } let takeWhileIterate: () -> Int = { var sum = 0 let i = takeWhile({$0 < iterations}, iterate({$0 + 1}, 0)) for b in i { sum += b } return sum } println(takeWhileIterate())
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!
This issue has been verified as resolved in Xcode 6.3 (6D520o) and can be closed.
This issue is still present in Xcode 6.2 Beta 3 (6C101).