Skip to content

Commit e297860

Browse files
mitchellhandrewrk
authored andcommitted
stage2: test changed behavior of c pointer resolution from stage1
stage1 peer resolves the given test to `[*c]u8` but stage2 makes that a const u8. I believe stage2 behavior is correct since the pointer itself is const.
1 parent f2a5d0b commit e297860

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/behavior/pointers.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ test "peer type resolution with C pointers" {
142142
try expect(@TypeOf(x4) == [*c]u8);
143143
}
144144

145+
test "peer type resolution with C pointer and const pointer" {
146+
// stage1 incorrectly resolves to [*]u8
147+
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
148+
149+
var ptr_c: [*c]u8 = undefined;
150+
const ptr_const: u8 = undefined;
151+
try expect(@TypeOf(ptr_c, &ptr_const) == [*c]const u8);
152+
}
153+
145154
test "implicit casting between C pointer and optional non-C pointer" {
146155
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
147156
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;

0 commit comments

Comments
 (0)