swift icon indicating copy to clipboard operation
swift copied to clipboard

[SR-282] Compiler crash unless whole mod opt. SIMD subscript

Open jepers opened this issue 10 years ago • 3 comments

Previous ID SR-282
Radar rdar://23730732
Original Reporter @jepers
Type Bug
Status Closed
Resolution Cannot Reproduce

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @jepers
Priority Medium

md5: 5771011c4a0f170795994ff54092811e

is duplicated by:

  • SR-301 Error when adding MutableCollectionType conformance to SIMD float4

Issue Description:

This program compiles and works as expected only when compiling with
-O -whole-module-optimization
otherwise it crashes the compiler.
It seems to have something to do with the set-part of the subscript.

$ cat > t.swift
import simd
protocol P {
    typealias Element
    var count: Int { get }
    subscript(index: Int) -> Element { get set }
    init()
}
extension float4 : P {
    typealias Element = Float
    var count: Int { return 4 }
}
func justToTestP<T: P where T.Element == Float>(_:T.Type) {
    var a = T(); for i in 0 ..< a.count { a[i] = Float(i) }
    print((0 ..< a.count).map { "\(a[$0])" }.joinWithSeparator(", "),
          "(So it worked!)")
}
justToTestP(float4)

$ swiftc -O -whole-module-optimization t.swift && ./t
0.0, 1.0, 2.0, 3.0 (So it worked!)

$ swiftc -O t.swift && ./t
Undefined symbols for architecture x86_64:
  "__TFV4simd6float4m9subscriptFSiSf", referenced from:
      __TTWV4simd6float41t1PS1_FS2_m9subscriptFSiqq_S2_7Element in t-c529a6.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

(Same crash with anything other than -O -whole-module-optimization.)

jepers avatar Dec 17 '15 21:12 jepers

@slavapestov, this looks like the same "retroactive conformance synthesizes accessors" problem, yes?

belkadan avatar Dec 17 '15 21:12 belkadan

Hi Jens,

This does not reproduce with me with the Swift 2.2 / Xcode 7.3 release, so I think it got fixed at some point in the development cycle.

Can you give it a try to see if you can still reproduce it with the newer compiler?

Mark

rudkx avatar Mar 22 '16 21:03 rudkx

I have verified that it is fixed in Xcode 7.3 / Swift 2.2.

jepers avatar Mar 23 '16 08:03 jepers