swift
swift copied to clipboard
[SR-287] Compiles to crashing (debug) or working (release) binary
| Previous ID | SR-287 |
| Radar | rdar://23602584 |
| Original Reporter | @jepers |
| Type | Bug |
| Status | Closed |
| Resolution | Cannot Reproduce |
Environment
OS X 10.11.2, Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 69940d166c)
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: 6e9be197d7086c7e7b431a11c929cea0
Issue Description:
The following little program will compile fine in both debug and release mode, but the resulting binary will crash or work depending on if it was built in debug or release mode respectively:
$ cat > t.swift
protocol DefaultInitializable { init() }
struct Empty : DefaultInitializable {}
protocol StaticArrayType : DefaultInitializable {
typealias Element: DefaultInitializable = Self
typealias Successor = StaticArraySuccessorOf<Self>
}
struct StaticArraySuccessorOf<T: StaticArrayType> : StaticArrayType {
typealias Predecessor = T
typealias Element = Predecessor.Element
var storage = (Element(), Predecessor())
}
extension Float : StaticArrayType {}
var threeFloats = Float.Successor.Successor()
print(strideofValue(threeFloats), "(so it worked!)") // 12 (strideof(Float) * 3 == 12)
$ swiftc -O t.swift && ./t
12 (so it worked!)
$ swiftc t.swift
(Note that it compiled fine)
$ ./t
Segmentation fault: 11
Seems to have been fixed. Can't reproduce in Xcode 8 beta 4.