0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/test
r00ster91 297b5d1074 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`.
History 2023-05-09 11:58:34 +03:00
..
behavior fix [x]u65529 and above overflowing 2023-05-09 11:58:34 +03:00
c_abi llvm: implement explicit Win64 and SysV calling conventions 2023-01-22 01:04:20 +02:00
cases Disallow named test decls with duplicate names 2023-05-08 10:59:06 +03:00
link std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
src std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
standalone std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
assemble_and_link.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
behavior.zig Disallow named test decls with duplicate names 2023-05-08 10:59:06 +03:00
cases.zig re-enable test-cases and get them all passing 2023-03-15 10:48:14 -07:00
cbe.zig re-enable test-cases and get them all passing 2023-03-15 10:48:14 -07:00
compare_output.zig Merge pull request #14671 from ziglang/multi-object-for 2023-02-19 10:10:59 -05:00
compile_errors.zig Port some stage1 test cases to stage2 2023-03-20 19:55:50 -04:00
gen_h.zig run zig fmt on src/ and test/ 2020-10-31 12:21:49 +02:00
link.zig Merge pull request #15101 from motiejus/glibc_compat 2023-04-06 17:15:58 -04:00
nvptx.zig amdgpu,nvptx: unify kernel calling conventions 2023-04-09 01:51:54 +02:00
run_translated_c.zig translate-c: Fix #12263 2022-10-10 22:29:56 +02:00
stack_traces.zig zig fmt: fix extra whitespace with multiline strings 2022-12-17 00:24:58 +02:00
standalone.zig Sema: fix empty infinite loops 2023-04-17 02:30:10 +03:00
tests.zig std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
translate_c.zig translate-c: fix codegen when C source has variables named the same as mangling prefixes 2023-04-26 17:30:46 +03:00