diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-05 15:53:36 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-05 15:53:36 -0400 |
| commit | c87a576cb5afaf54e68bae10119305af71aaa3a1 (patch) | |
| tree | 5deeb1a955da7b4e593f6b26703badbc8c3a4b77 /test/compile_errors.zig | |
| parent | ba7836ea4859b244bf2c7749cc91853ea5512e26 (diff) | |
| download | zig-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.zig | 12 |
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, |
