Xcode 6.3 (6D554n): [Swift] Compiler crash using unsafeAddressOf of generic type conforming to protocol (when compiled with -O, FMO)

Originator:janoschhildebrand
Number:rdar://20343372 Date Originated:30-Mar-2015
Status:Closed Resolved:8-Jun-2015
Product:Developer Tools Product Version:Xcode 6.3 (6D554n)
Classification:Serious Bug Reproducible:Always
 
Summary:
The following code crashes the Swift compiler:

protocol Protocol: class { }
class Element: Protocol { }
crash(Element())

when the following function is declared in a separate file:

func crash<T: Protocol>(element: T) {
    let addr = unsafeAddressOf(element)
}

and the files are compiled using -O and FMO is enabled.

An example project and crash report are attached.

Steps to Reproduce:
1. Open the attached Xcode project. It is already configured to build using -O and with FMO.
2. Build

Expected Results:
The code should compile successfully.

Actual Results:
The Swift compiler crashes

Version:
Xcode 6.3 (6D554n)
Apple Swift version 1.2 (swiftlang-602.0.47.4 clang-602.0.48)
10.10.2 (14C1514)

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!