authorgravatar for evan@lagerdata.comEvan Haas <evan@lagerdata.com> 2021-03-09 07:34:21-08:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-03-17 09:06:47+02:00
logf76bd56588e556ea580c1faa63667cc9264cc218
tree07253660fa9786736a14965fcf95f2ad8b2932e3
parent715370a10a1d8cd2b553e6b1b8a328a637707375

translate-c: fix __builtin_object_size

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

1 files changed, 1 insertions(+), 1 deletions(-)

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