feat: add as type casting

This commit is contained in:
2026-04-22 22:40:19 +02:00
parent e66a4ee736
commit 041a49e574
13 changed files with 350 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
[code]
fn truncate_i32_to_i8(x: i32) -> i8 {
return x as i8;
}
fn extend_u8_to_i32(x: u8) -> i32 {
return x as i32;
}
[harness]
#include <stdint.h>
extern int8_t truncate_i32_to_i8(int32_t x);
extern int32_t extend_u8_to_i32(uint8_t x);
int main() {
if (truncate_i32_to_i8(257) != 1) return 1; // 257 = 0x0101, truncated to 8 bits is 0x01
if (extend_u8_to_i32(255) != 255) return 2;
return 0;
}
[expected_return_code]
0