Skip to content

Program is crashing when trying to access sliced data via subscript #1601

@flexlixrup

Description

@flexlixrup

Describe the bug

When trying to access a Data slice via a subscript, the program crashes with Signal 5. When I first copy the slice into new Data access works

To Reproduce
Sample code to reproduce the behavior.

import Foundation

let data = Data([0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D])
let slice = data[1 ..< 14]
let sliceNew = Data(slice)
let notCrashing = sliceNew[0]
print("Not crashing correct: \(notCrashing)")
let crashing = slice[0]
print("Crashing: \(crashing)")

Expected behavior

We don't crash when we access the data slice

Configuration (please complete the following information):

Apple Swift version 6.2.1 (swift-6.2.1-RELEASE)
Target: arm64-apple-macosx26.0
Build config: +assertions
Darwin Felix-MacBook.local 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions