zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f76bd56588e556ea580c1faa63667cc9264cc218 (tree)
parent 715370a10a1d8cd2b553e6b1b8a328a637707375
Author: Evan Haas <evan@lagerdata.com>
Date:   Tue,  9 Mar 2021 07:34:21 -0800

translate-c: fix __builtin_object_size

Previous code assumed `c_long` and `usize` were the same size.
Use `isize` instead.

Diffstat:
Mlib/std/c/builtins.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/std/c/builtins.zig b/lib/std/c/builtins.zig @@ -140,7 +140,7 @@ pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) u // If it is not possible to determine which objects ptr points to at compile time, // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 // for type 2 or 3. - if (ty == 0 or ty == 1) return @bitCast(usize, -@as(c_long, 1)); + if (ty == 0 or ty == 1) return @bitCast(usize, -@as(isize, 1)); if (ty == 2 or ty == 3) return 0; unreachable; }