# InLineArray issue with big arrays

**URL:** <https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102>\
**Category:** Using Swift\
**Created:** [April 18, 2026, 6:36am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102 "2026-04-18T06:36:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabino](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sabino/32/34232_2.png) [@sabino](https://forums.swift.org/u/sabino)\
**Post date:** [April 18, 2026, 6:36am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/1 "2026-04-18T06:36:00Z")

</div>

Not an expert here.

this code fails to build in Xcode without specifying any error. I was expecting to have more info on the Type itself. why is that?

```swift
@available(macOS 26.0, *)
let a: InlineArray<9_223_372_036_854_775_807_000_000_000_000_000_000_000_000_000_000_000_000, Int> = InlineArray(repeating: 0)

```

---

<div class="post-metadata">

**Author:** ![Diggory](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/diggory/32/4320_2.png) [@Diggory](https://forums.swift.org/u/Diggory)\
**Post date:** [April 18, 2026, 7:04am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/2 "2026-04-18T07:04:22Z")

</div>

That number is larger than `Int.max` (you’d need a 256 bit architecture to hold an int of that size)

I would guess that the type checker is unable to infer what type your literal is meant to be.

I only have my phone to hand so can only check the error via a web based swift compiler which emits the following error:

```swift
exit status 1

Main.swift:5:20: error: expected type let a: InlineArray<9_223_372_036_854_775_807_000_000_000_000_000_000_000_000_000_000_000_000, Int> = InlineArray(repeating: 0) ^

error: fatalError

```

You can see Int’s error if you use the non-shorthand initialiser:

```swift
let tooBigInt = Int(9_223_372_036_854_775_807_000_000_000_000_000_000_000_000_000_000_000_000)

```

```swift
exit status 1
Main.swift:5:21: error: integer literal '9223372036854775807000000000000000000000000000000000000' overflows when stored into 'Int' let tooBigInt = Int(9_223_372_036_854_775_807_000_000_000_000_000_000_000_000_000_000_000_000) ^

```

If you want to deal with Integers that wide, you may need a special type. e.g.

> **[GitHub - attaswift/BigInt: Arbitrary-precision arithmetic in pure Swift](https://github.com/attaswift/BigInt)**
>
> Arbitrary-precision arithmetic in pure Swift

---

<div class="post-metadata">

**Author:** ![Diggory](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/diggory/32/4320_2.png) [@Diggory](https://forums.swift.org/u/Diggory)\
**Post date:** [April 18, 2026, 7:55am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/3 "2026-04-18T07:55:34Z")

</div>

Hmm, you're right, Xcode seems to report failure of compilation, but there's no report in the issue navigator or console.

I'd suggest filing a radar/feedback report however _[bitter rant about Apple's attitude to bug reporting self-censored...]_

---

<div class="post-metadata">

**Author:** ![sabino](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sabino/32/34232_2.png) [@sabino](https://forums.swift.org/u/sabino)\
**Post date:** [April 18, 2026, 8:21am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/4 "2026-04-18T08:21:58Z")

</div>

I don’t need a number that big. I was messing with the InLineArray and expecting to be yelled at by Xcode. Instead I found -3 is acceptable as count, like`let a: InlineArray<-3, Int> = InlineArray(repeating: 0)`.

never filed a bug, I don't know where to start anyway

---

<div class="post-metadata">

**Author:** ![NotTheNHK](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/notthenhk/32/43199_2.png) [@NotTheNHK](https://forums.swift.org/u/NotTheNHK)\
**Post date:** [April 18, 2026, 8:30am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/5 "2026-04-18T08:30:48Z")

</div>

You can open an issue here: [Issues · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/issues)

---

<div class="post-metadata">

**Author:** ![Diggory](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/diggory/32/4320_2.png) [@Diggory](https://forums.swift.org/u/Diggory)\
**Post date:** [April 18, 2026, 8:51am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/6 "2026-04-18T08:51:42Z")

</div>

```swift
struct InlineArray<let count : Int, Element> where Element : ~Copyable

```

`count` is an `Int`, so can be any value in the range `Int.min` to `Int.max` (on an Apple Silicon Mac that's +/- `9223372036854775807`)

Obviously it doesn't make sense to have a negative count. However there are [reasons](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#UInt) why Int is used instead of Unsigned Int.

> A consistent use of `Int` for integer values aids code interoperability, avoids the need to convert between different number types, and matches integer type inference

---

<div class="post-metadata">

**Author:** ![sabino](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sabino/32/34232_2.png) [@sabino](https://forums.swift.org/u/sabino)\
**Post date:** [April 18, 2026, 1:20pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/7 "2026-04-18T13:20:37Z")

</div>

Looks like that’s more of a compromise than a bug. The only thing that remains uncovered is maybe if a more specific error should be raised on build. However, I guess if this is about Swift or Xcode related. And, speaking about real world example, I wonder if computations on a bidimensional matrix of Int.max size are feasible.

---

<div class="post-metadata">

**Author:** ![NotTheNHK](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/notthenhk/32/43199_2.png) [@NotTheNHK](https://forums.swift.org/u/NotTheNHK)\
**Post date:** [April 18, 2026, 1:34pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/8 "2026-04-18T13:34:42Z")

</div>

> [@sabino](#):
>
> Instead I found -3 is acceptable as count, like `let a: InlineArray<-3, Int> = InlineArray(repeating: 0)`.

On the snapshot and nightly builds, this no longer compiles. However, it still does not produce a diagnostic and instead causes a compiler crash: [Godbolt](https://swift.godbolt.org/z/r8he6x6Ef)

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [April 18, 2026, 10:30pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/9 "2026-04-18T22:30:51Z")

</div>

And when the number is big (e.g. 1000\_000\_000) the app crashes at runtime.  
All of these issues are not ideal of course, but far from pressing.

---

<div class="post-metadata">

**Author:** ![sabino](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sabino/32/34232_2.png) [@sabino](https://forums.swift.org/u/sabino)\
**Post date:** [April 19, 2026, 10:34am UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/10 "2026-04-19T10:34:57Z")

</div>

In a playground, using a negative value for count, I got `Swift/UnsafeBufferPointer.swift:74: Fatal error: UnsafeMutableBufferPointer with negative count` and that's fair.

Instead, using 1\_000\_000\_000 the playground managed to allocate near 4 gb of memory before crashing with

```swift
Playground execution failed:

error: Expression execution was interrupted: EXC_BAD_ACCESS (code=1, address=0xffffffff926d75a0).

The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffff926d75a0)

  * frame #0: 0x000000010b526fc0 PlaygroundLogger`playground_logger_initialize

    frame #1: 0x000000010b478794 $__lldb_expr46`main at playground45-380736..cpp:8:1

    frame #2: 0x00000001009c3bf4 com.apple.dt.Xcode.PlaygroundStub-macosx`playgroundExecutionWillFinish + 4

```

it took a bunch of minutes on an apple silicon, so looks like the whole point it's not very productive. Likely, an InlineArray is going to fill a lot of memory and is killed. I had a similar behavior on Godbolt, and the accepted magnitude was more than what was acceptable on my Mac.

---

<div class="post-metadata">

**Author:** ![KeithBauerANZ](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/keithbaueranz/32/27897_2.png) [@KeithBauerANZ](https://forums.swift.org/u/KeithBauerANZ)\
**Post date:** [April 19, 2026, 9:47pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/11 "2026-04-19T21:47:03Z")

</div>

@sabino make sure you're putting your large `InlineArray` on the heap, not the stack (the stack is only a few MB, and you're asking for many GB of storage; that's never going to work). Also make sure that the size of your InlineArray is reasonable given the amount of RAM you have (eg. your billion Ints is already 8GB).

For this much data, there's probably no reason to actually use an InlineArray anyway, though; a regular `ContiguousArray` will be fine since you need a heap allocation anyway.

That said, I still found issues; I've filed [#88549](https://github.com/swiftlang/swift/issues/88549) (`InlineArray` takes _compilation_ time proportional to number of elements) and [#88550](https://github.com/swiftlang/swift/issues/88550) (Large `InlineArray` crashes) based on this thread.

---

<div class="post-metadata">

**Author:** ![Nobody1707](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nobody1707/32/2169_2.png) [@Nobody1707](https://forums.swift.org/u/Nobody1707)\
**Post date:** [April 19, 2026, 10:33pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/12 "2026-04-19T22:33:53Z")

</div>

I find the existence of [#88549](https://github.com/swiftlang/swift/issues/88549) disturbing. I thought the main selling point of `InlineArray` over the pre-existing homogeneous tuples was that it didn't have this O(N) time type checking issue.

---

<div class="post-metadata">

**Author:** ![sabino](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sabino/32/34232_2.png) [@sabino](https://forums.swift.org/u/sabino)\
**Post date:** [April 20, 2026, 2:18pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/13 "2026-04-20T14:18:27Z")

</div>

Thanks, I’m going to observe and learn from your bug reports. And of course I’ll dive deeper in the ContiguousArray. This could be a better storage for the Matrix struct I’m studying.

---

<div class="post-metadata">

**Author:** ![sabino](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sabino/32/34232_2.png) [@sabino](https://forums.swift.org/u/sabino)\
**Post date:** [April 20, 2026, 2:22pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/14 "2026-04-20T14:22:46Z")

</div>

The main selling point in my case is that I can build 2 Matrices with [Integer Generic Parameters](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/genericparametersandarguments/#Integer-Generic-Parameters) with different count and get 2 different types, and that's huge in my code because I can safely conform Matrix type to AdditiveArithmetic. I was only hoping to use a variable as parameter but that's not allowed. Maybe it's a slippery slope, and it will be added in future...

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [April 20, 2026, 2:40pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/15 "2026-04-20T14:40:03Z")

</div>

I don't recall "builds fast" ever being brought up. I don't see why `InlineArray<4, String>` would be any faster to compile than `[String]` (given the same number of elements). It still has to separately type check each element of the literal, and there have been no specific improvements to literal checking I recall. It seems like there could be (if I check a string literal once, and the collection is all string literals, I shouldn't need to check any more) but I don't think the collection type impacts this at all.

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [April 20, 2026, 2:53pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/16 "2026-04-20T14:53:24Z")

</div>

It's not actually a type checker issue. I sampled it and the problem is in the [`LoadableByAddress` SIL pass](https://github.com/swiftlang/swift/issues/88549#issuecomment-4281804997), which must be doing some linear (or worse?) work to determine if an `InlineArray<1_000_000_000, _>` can fit in a register. (Spoiler: _It can't_)

---

<div class="post-metadata">

**Author:** ![Nobody1707](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nobody1707/32/2169_2.png) [@Nobody1707](https://forums.swift.org/u/Nobody1707)\
**Post date:** [April 20, 2026, 5:51pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/17 "2026-04-20T17:51:49Z")

</div>

It was brought up as one of the reasons why it was an improvement over the current c array importing, and why changing the importer from using tuples for c arrays to InlineArray was listed as a future direction.

But, if it's not actually a type checking issue here, then my point was irrelevant anyway.

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [April 20, 2026, 6:26pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/18 "2026-04-20T18:26:08Z")

</div>

> [@Nobody1707](#):
>
> I find the existence of [#88549](https://github.com/swiftlang/swift/issues/88549) disturbing. I thought the main selling point of `InlineArray` over the pre-existing homogeneous tuples was that it didn't have this O(N) time type checking issue.

The culprit here looks like it’s the optimizer, not the type checker.

---

<div class="post-metadata">

**Author:** ![KeithBauerANZ](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/keithbaueranz/32/27897_2.png) [@KeithBauerANZ](https://forums.swift.org/u/KeithBauerANZ)\
**Post date:** [April 20, 2026, 9:16pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/19 "2026-04-20T21:16:18Z")

</div>

You can use integer generics on your own type, and still use ContiguousArray as the storage:

```swift
struct Matrix<let columns: Int, let rows: Int, Element: BinaryFloatingPoint> {
    var storage: ContiguousArray<Element>
    init() {
        storage = ContiguousArray(repeating: .zero, count: columns * rows)
    }
}

```

or similar

---

<div class="post-metadata">

**Author:** ![sabino](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sabino/32/34232_2.png) [@sabino](https://forums.swift.org/u/sabino)\
**Post date:** [April 20, 2026, 10:36pm UTC](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102/20 "2026-04-20T22:36:40Z")

</div>

Yes, that’s exactly what I’m doing. But I can’t do this:

```swift
let n = 1

let v: InlineArray<n, Int>…

```

[Next page](https://forums.swift.org/t/inlinearray-issue-with-big-arrays/86102.md?page=2)
