Commit 62f54aa39c
src/Sema.zig
@@ -18458,6 +18458,17 @@ fn coerceInMemoryAllowed(
if (dest_ty.eql(src_ty, target))
return .ok;
+ // Differently-named integers with the same number of bits.
+ if (dest_ty.zigTypeTag() == .Int and src_ty.zigTypeTag() == .Int) {
+ const dest_info = dest_ty.intInfo(target);
+ const src_info = src_ty.intInfo(target);
+ if (dest_info.signedness == src_info.signedness and
+ dest_info.bits == src_info.bits)
+ {
+ return .ok;
+ }
+ }
+
// Pointers / Pointer-like Optionals
var dest_buf: Type.Payload.ElemType = undefined;
var src_buf: Type.Payload.ElemType = undefined;
test/behavior/cast.zig
@@ -973,7 +973,8 @@ test "variable initialization uses result locations properly with regards to the
}
test "cast between C pointer with different but compatible types" {
- if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
const S = struct {
fn foo(arg: [*]c_ushort) u16 {
@@ -985,6 +986,7 @@ test "cast between C pointer with different but compatible types" {
}
};
try S.doTheTest();
+ comptime try S.doTheTest();
}
test "peer type resolve string lit with sentinel-terminated mutable slice" {