@floatToInt now has safety-checked undefined behavior
when the integer part does not fit in the destination integer type * Also fix incorrect safety triggered for integer casting an `i32` to a `u7`. closes #1138 * adds compiler-rt function: `__floatuntidf`
This commit is contained in:
@@ -1,6 +1,23 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"@floatToInt comptime safety",
|
||||
\\comptime {
|
||||
\\ _ = @floatToInt(i8, f32(-129.1));
|
||||
\\}
|
||||
\\comptime {
|
||||
\\ _ = @floatToInt(u8, f32(-1.1));
|
||||
\\}
|
||||
\\comptime {
|
||||
\\ _ = @floatToInt(u8, f32(256.1));
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:9: error: integer value '-129' cannot be stored in type 'i8'",
|
||||
".tmp_source.zig:5:9: error: integer value '-1' cannot be stored in type 'u8'",
|
||||
".tmp_source.zig:8:9: error: integer value '256' cannot be stored in type 'u8'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"use c_void as return type of fn ptr",
|
||||
\\export fn entry() void {
|
||||
|
||||
Reference in New Issue
Block a user