Swift: Crash on device when enum parameter has associated struct value
| Originator: | thephatmann | ||
| Number: | rdar://19579256 | Date Originated: | 23-Jan-2015 11:38 AM |
| Status: | Duplicate of 19792160 | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.1.1 |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary: If an enum with an associated struct value is passed as a parameter to a function, in certain circumstances the compiler will incorrectly pop the parameter off the stack, leading a to a Bad Access crash. Steps to Reproduce: Run the attached project on an iPhone 5S with iOS 8.1.2. Expected Results: App should show blank screen. Actual Results: App crashes when the function âfâ is called. Regression: The crash does not happen in the simulator. I did not test other devices or different iOS versions. Notes: The crash will not occur if one of the following is changed: * use associated class value instead of struct * function âfâ returns Void instead of a tuple * enum has only one associated value * struct only has one property So it is a very fragile combination of events that causes the crash. In my app, I changed the structs to classes as a workaround.
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!