Latest released swift compiler dies with signal(4) on trivial example

I hope this is the correct group, and apologies if not. Pretty sure this compiler segfault is triggered by something amiss in the CGFloat/Double interoperability recently released.

Ringil$ swiftc --version
swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: x86_64-apple-macosx12.0
Ringil$ swiftc cruft.swift
error: compile command failed due to signal 4 (use -v to see invocation)
// File: cruft.swift:
import Foundation

struct SizeHolder {
    let size: CGSize
}

// Replace Double? with CGFloat? to avoid crash.
func height(sizeHolder: SizeHolder?) -> Double? {
    return sizeHolder?.size.height
}

let value = height(sizeHolder: nil)

cc @xedin

Thanks for the report! This is fixed in [Diagnostics] A tailored diagnostic for Double<->CGFloat conversion via optional chaining by xedin · Pull Request #40047 · apple/swift · GitHub

2 Likes

I’ve been using Swift since it came out, and this is one of the exceedingly rare times the compiler just up and died on me. Luckily I was able to guess where the bug was because I had just added new code: compilers dying out of the blue is one of my worst nightmares.

Happy to know it’s already fixed already in the toolchain. Thanks!

1 Like