aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-05 15:53:36 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-05 15:53:36 -0400
commitc87a576cb5afaf54e68bae10119305af71aaa3a1 (patch)
tree5deeb1a955da7b4e593f6b26703badbc8c3a4b77 /test/compile_errors.zig
parentba7836ea4859b244bf2c7749cc91853ea5512e26 (diff)
downloadzig-c87a576cb5afaf54e68bae10119305af71aaa3a1.tar.gz
zig-c87a576cb5afaf54e68bae10119305af71aaa3a1.zip
stage1 compile error instead of crashing for unsupported comptime ptr cast
See #955
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index f89dea1921..cbca4bb7e3 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -2,6 +2,18 @@ const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "load too many bytes from comptime reinterpreted pointer",
+ \\export fn entry() void {
+ \\ const float: f32 = 5.99999999999994648725e-01;
+ \\ const float_ptr = &float;
+ \\ const int_ptr = @ptrCast(*const i64, float_ptr);
+ \\ const int_val = int_ptr.*;
+ \\}
+ ,
+ ".tmp_source.zig:5:28: error: attempt to read 8 bytes from pointer to f32 which is 4 bytes",
+ );
+
+ cases.add(
"invalid type used in array type",
\\const Item = struct {
\\ field: SomeNonexistentType,