# fix \`\[x\]u65529\` and above overflowing · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/297b5d1074008b52a8d08a32c9f3281542105bdd)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 297b5d1074008b52a8d08a32c9f3281542105bdd

Requested commit: 297b5d1074008b52a8d08a32c9f3281542105bdd

Commit: 297b5d1074008b52a8d08a32c9f3281542105bdd

Tree: fbff3796a3c6bd3a214d2f9bfc68b58a77538ea1

Author: r00ster91

Committer: Veikka Tuominen

## Message

````
fix `[x]u65529` and above overflowing

```
$ cat overflow.zig
test {
    var a: [1]u65535 = undefined;
    _ = a;
}
$ zig-out/bin/zig test overflow.zig
thread 290266 panic: integer overflow
zig/src/type.zig:3604:55: 0xada43d in intAbiAlignment (zig)
            std.math.ceilPowerOfTwoPromote(u16, (bits + 7) / 8),
                                                      ^
zig/src/type.zig:3598:42: 0xadd4ea in intAbiSize (zig)
        const alignment = intAbiAlignment(bits, target);
                                         ^
zig/src/type.zig:3500:61: 0x92be91 in abiSizeAdvanced (zig)
                return AbiSizeAdvanced{ .scalar = intAbiSize(bits, target) };
                                                            ^
zig/src/type.zig:3385:62: 0x928933 in abiSizeAdvanced (zig)
                switch (try payload.elem_type.abiSizeAdvanced(target, strat)) {
                                                             ^
zig/src/type.zig:3268:32: 0x92c012 in abiSize (zig)
        return (abiSizeAdvanced(ty, target, .eager) catch unreachable).scalar;
                               ^
```
This is only noticed in a debug build of zig and silently does the wrong
thing and overflows in release builds.

This happened to `[x]u65529` and above because of the ` + 7` on a `u16`.

````

## Parents

- [f40539e5d83365412bf8c6973ce867125ea36faf](https://git.cafe/gitcafe/zig/commit/f40539e5d83365412bf8c6973ce867125ea36faf?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/297b5d1074008b52a8d08a32c9f3281542105bdd?format=markdown)
