Data.replaceSubrange crashes on devices 32 bits

  1. Steps to reproduce:

Environment: Latest Swift (happens on earlier version as well), Xcode version, device 32 bits.

var data = Data.init(count: 837933)     // count is larger than Int16.max
data.removeSubrange(0..<834385)         // upperBound is larger than Int16.max
  1. Seems that it's crashed in
    internal struct InlineSlice {
    ...

    @inlinable // This is @inlinable as a convenience initializer.
    init(_ large: LargeSlice) {
       assert(large.range.lowerBound < HalfInt.max)
       assert(large.range.upperBound < HalfInt.max)
       self.init(large.storage, range: large.range)
    }
    
    ...
    

    }

Because HalfInt on 32 bits devices is Int16, so assert large.range.upperBound < HalfInt.max is failed.

Thanks for the bug report, we'll take a look (64029630).

1 Like
Terms of Service

Privacy Policy

Cookie Policy