Error compiling simple Span usage example

Having a keen interest in efficient buffer manipulation mechanisms, I attempted to compile a very simple demo of Span usage based on the code mentioned on the new swift.org homepage.

import Foundation

// Vectorized check that a utf8 buffer is all ASCII
func isASCII(utf8: Span<SIMD16<UInt8>>) -> Bool {
  // combine all the code units into a single entry
  utf8.indices.reduce(into: SIMD16()) {
    // fold each set of code units into the result
    $0 |= utf8[$1]
  }
  // check that every entry is in the ASCII range
  .max() < 0x80
}

func foo() {
    var span = Span<SIMD16<UInt8>>(_unsafeStart: &buffer, count: 1)
    print(isASCII(utf8: span))
}

var buffer: SIMD16<UInt8> = .init(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)

foo()

This code fails to compile with the error:

Command SwiftCompile failed with a nonzero exit code

I'm on Xcode 16.4 with the latest Swift toolchain 2025-06-03

Any ideas?

I have filed a bug reporting your issue.

1 Like

Just tested with Xcode 26 beta (Swift 6.2) with success !