| ... | @@ -10387,7 +10387,26 @@ fn bar(f: *Foo) void { | ... | @@ -10387,7 +10387,26 @@ fn bar(f: *Foo) void { |
| 10387 | {#header_close#} | 10387 | {#header_close#} |
| 10388 | | 10388 | |
| 10389 | {#header_open|Out of Bounds Float to Integer Cast#} | 10389 | {#header_open|Out of Bounds Float to Integer Cast#} |
| 10390 | <p>TODO</p> | 10390 | <p> |
| | 10391 | This happens when casting a float to an integer where the float has a value outside the |
| | 10392 | integer type's range. |
| | 10393 | </p> |
| | 10394 | <p>At compile-time:</p> |
| | 10395 | {#code_begin|test_err|test_comptime_out_of_bounds_float_to_integer_cast|float value '4294967296' cannot be stored in integer type 'i32'#} |
| | 10396 | comptime { |
| | 10397 | 	const float: f32 = 4294967296; |
| | 10398 | 	const int: i32 = @intFromFloat(float); |
| | 10399 | 	_ = int; |
| | 10400 | } |
| | 10401 | {#code_end#} |
| | 10402 | <p>At runtime:</p> |
| | 10403 | {#code_begin|exe_err|runtime_out_of_bounds_float_to_integer_cast#} |
| | 10404 | pub fn main() void { |
| | 10405 | 	var float: f32 = 4294967296; |
| | 10406 | 	var int: i32 = @intFromFloat(float); |
| | 10407 | 	_ = int; |
| | 10408 | } |
| | 10409 | {#code_end#} |
| 10391 | {#header_close#} | 10410 | {#header_close#} |
| 10392 | | 10411 | |
| 10393 | {#header_open|Pointer Cast Invalid Null#} | 10412 | {#header_open|Pointer Cast Invalid Null#} |