stage1: fix crash on slice byte reinterpretation

This commit is contained in:
xackus
2020-06-08 19:06:37 +02:00
committed by Andrew Kelley
parent c405844b0a
commit 0d40cb6255
2 changed files with 27 additions and 5 deletions

View File

@@ -7495,4 +7495,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
":22:12: error: cannot compare types '?[3]i32' and '[3]i32'",
":22:12: note: operator not supported for type '[3]i32'",
});
cases.add("slice cannot have its bytes reinterpreted",
\\export fn foo() void {
\\ const bytes = [1]u8{ 0xfa } ** 16;
\\ var value = @ptrCast(*const []const u8, &bytes).*;
\\}
, &[_][]const u8{
":3:52: error: slice '[]const u8' cannot have its bytes reinterpreted",
});
}