[SR-8806] Swift (4.2) release compilation has code execute in unexpected order #51314
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
optimized only
Flag: An issue whose reproduction requires optimized compilation
Attachment: Download
Environment
Swift 4.2 (Xcode 10), macOS 10.13.6 in the iPhone X simulator or on-device (iPhone X).
Additional Detail from JIRA
md5: 6d1b5c045d726d64ec86996e4dd6a8fb
Issue Description:
In the attached project when compiled the expected behaviour would be that `A` is printed 4 times, then "B" is printed after which "C" is printed and a crash occurs.
This works completely normal on Debug compilation, on release however just "C" is printed and then a crash occurs.
In my own codebase, the print statements printing `A` are setup code that is required to execute first in order for the `State.default` to be initialized. The crash in my app occurs because I `try!` the result knowing it must've been set up resulting in the crash leading me to finding this.
The text was updated successfully, but these errors were encountered: