- 
                Notifications
    
You must be signed in to change notification settings  - Fork 10.6k
 
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
An empty InlineArray is documented as having a one byte alignment.
For an element type with alignment > 1, accessing the span property of an empty InlineArray fails at runtime due to a violation of the alignment precondition used by Span which expects the base pointer to be aligned for the element type.
Likely either Span needs to relax this precondition for empty spans or InlineArray needs to provide a nil base address when creating the Span if it is empty.
Reproduction
func crash() {
    let array: [0 of Int] = []
    // Fatal error: baseAddress must be properly aligned to access Element
    let span = array.span
}
crash()Stack dump
n/a
Expected behavior
It should be possible to get a span for an empty InlineArray.
Environment
Xcode 26.1
swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels