Xcode-beta (7A121l): Fields In Initializer Being Set From Wrong Local Variable

Originator:john
Number:rdar://21673308 Date Originated:04-Jul-2015 02:46 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A121l)
Classification:Serious Bug Reproducible:Rarely
 
Summary:
I’ve encountered a problem in an initializer where three variables are captured in a single if let clause, and are then used to initialized fields on a struct. The first field is assigned the value from the first captured variable, but instead receives the value from the last captured variable. I’ve attached a project that demonstrates the issue.

Steps to Reproduce:
1. Create an initializer that takes in a dictionary
2. Unwrap several values from that dictionary in an if let clause
3. Store those values in fields on the data structure.

Expected Results:
The first field should get the value from its corresponding local variable.

Actual Results:
The first field gets the value from the third local variable.

Regression:

Notes:
Changing the order in which the variables are captured in the if let clause will cause all three fields to be set properly.  Changing the order in which the fields are assigned does not fix the problem. The problem happens at optimization level -O, but not -Onone

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!