| ... | @@ -1410,8 +1410,10 @@ fn baz(a: i32) {} | ... | @@ -1410,8 +1410,10 @@ fn baz(a: i32) {} |
| 1410 | )SOURCE"); | 1410 | )SOURCE"); |
| 1411 | | 1411 | |
| 1412 | add_debug_safety_case("integer addition overflow", R"SOURCE( | 1412 | add_debug_safety_case("integer addition overflow", R"SOURCE( |
| | 1413 | error Whatever; |
| 1413 | pub fn main(args: [][]u8) -> %void { | 1414 | pub fn main(args: [][]u8) -> %void { |
| 1414 | add(65530, 10); | 1415 | const x = add(65530, 10); |
| | 1416 | if (x == 0) return error.Whatever; |
| 1415 | } | 1417 | } |
| 1416 | #static_eval_enable(false) | 1418 | #static_eval_enable(false) |
| 1417 | fn add(a: u16, b: u16) -> u16 { | 1419 | fn add(a: u16, b: u16) -> u16 { |
| ... | @@ -1420,8 +1422,10 @@ fn add(a: u16, b: u16) -> u16 { | ... | @@ -1420,8 +1422,10 @@ fn add(a: u16, b: u16) -> u16 { |
| 1420 | )SOURCE"); | 1422 | )SOURCE"); |
| 1421 | | 1423 | |
| 1422 | add_debug_safety_case("integer subtraction overflow", R"SOURCE( | 1424 | add_debug_safety_case("integer subtraction overflow", R"SOURCE( |
| | 1425 | error Whatever; |
| 1423 | pub fn main(args: [][]u8) -> %void { | 1426 | pub fn main(args: [][]u8) -> %void { |
| 1424 | sub(10, 20); | 1427 | const x = sub(10, 20); |
| | 1428 | if (x == 0) return error.Whatever; |
| 1425 | } | 1429 | } |
| 1426 | #static_eval_enable(false) | 1430 | #static_eval_enable(false) |
| 1427 | fn sub(a: u16, b: u16) -> u16 { | 1431 | fn sub(a: u16, b: u16) -> u16 { |
| ... | @@ -1430,8 +1434,10 @@ fn sub(a: u16, b: u16) -> u16 { | ... | @@ -1430,8 +1434,10 @@ fn sub(a: u16, b: u16) -> u16 { |
| 1430 | )SOURCE"); | 1434 | )SOURCE"); |
| 1431 | | 1435 | |
| 1432 | add_debug_safety_case("integer multiplication overflow", R"SOURCE( | 1436 | add_debug_safety_case("integer multiplication overflow", R"SOURCE( |
| | 1437 | error Whatever; |
| 1433 | pub fn main(args: [][]u8) -> %void { | 1438 | pub fn main(args: [][]u8) -> %void { |
| 1434 | mul(300, 6000); | 1439 | const x = mul(300, 6000); |
| | 1440 | if (x == 0) return error.Whatever; |
| 1435 | } | 1441 | } |
| 1436 | #static_eval_enable(false) | 1442 | #static_eval_enable(false) |
| 1437 | fn mul(a: u16, b: u16) -> u16 { | 1443 | fn mul(a: u16, b: u16) -> u16 { |
| ... | @@ -1440,8 +1446,10 @@ fn mul(a: u16, b: u16) -> u16 { | ... | @@ -1440,8 +1446,10 @@ fn mul(a: u16, b: u16) -> u16 { |
| 1440 | )SOURCE"); | 1446 | )SOURCE"); |
| 1441 | | 1447 | |
| 1442 | add_debug_safety_case("integer negation overflow", R"SOURCE( | 1448 | add_debug_safety_case("integer negation overflow", R"SOURCE( |
| | 1449 | error Whatever; |
| 1443 | pub fn main(args: [][]u8) -> %void { | 1450 | pub fn main(args: [][]u8) -> %void { |
| 1444 | neg(-32768); | 1451 | const x = neg(-32768); |
| | 1452 | if (x == 0) return error.Whatever; |
| 1445 | } | 1453 | } |
| 1446 | #static_eval_enable(false) | 1454 | #static_eval_enable(false) |
| 1447 | fn neg(a: i16) -> i16 { | 1455 | fn neg(a: i16) -> i16 { |
| ... | @@ -1450,8 +1458,10 @@ fn neg(a: i16) -> i16 { | ... | @@ -1450,8 +1458,10 @@ fn neg(a: i16) -> i16 { |
| 1450 | )SOURCE"); | 1458 | )SOURCE"); |
| 1451 | | 1459 | |
| 1452 | add_debug_safety_case("signed shift left overflow", R"SOURCE( | 1460 | add_debug_safety_case("signed shift left overflow", R"SOURCE( |
| | 1461 | error Whatever; |
| 1453 | pub fn main(args: [][]u8) -> %void { | 1462 | pub fn main(args: [][]u8) -> %void { |
| 1454 | shl(-16385, 1); | 1463 | const x = shl(-16385, 1); |
| | 1464 | if (x == 0) return error.Whatever; |
| 1455 | } | 1465 | } |
| 1456 | #static_eval_enable(false) | 1466 | #static_eval_enable(false) |
| 1457 | fn shl(a: i16, b: i16) -> i16 { | 1467 | fn shl(a: i16, b: i16) -> i16 { |
| ... | @@ -1460,8 +1470,10 @@ fn shl(a: i16, b: i16) -> i16 { | ... | @@ -1460,8 +1470,10 @@ fn shl(a: i16, b: i16) -> i16 { |
| 1460 | )SOURCE"); | 1470 | )SOURCE"); |
| 1461 | | 1471 | |
| 1462 | add_debug_safety_case("unsigned shift left overflow", R"SOURCE( | 1472 | add_debug_safety_case("unsigned shift left overflow", R"SOURCE( |
| | 1473 | error Whatever; |
| 1463 | pub fn main(args: [][]u8) -> %void { | 1474 | pub fn main(args: [][]u8) -> %void { |
| 1464 | shl(0b0010111111111111, 3); | 1475 | const x = shl(0b0010111111111111, 3); |
| | 1476 | if (x == 0) return error.Whatever; |
| 1465 | } | 1477 | } |
| 1466 | #static_eval_enable(false) | 1478 | #static_eval_enable(false) |
| 1467 | fn shl(a: u16, b: u16) -> u16 { | 1479 | fn shl(a: u16, b: u16) -> u16 { |
| ... | @@ -1470,8 +1482,9 @@ fn shl(a: u16, b: u16) -> u16 { | ... | @@ -1470,8 +1482,9 @@ fn shl(a: u16, b: u16) -> u16 { |
| 1470 | )SOURCE"); | 1482 | )SOURCE"); |
| 1471 | | 1483 | |
| 1472 | add_debug_safety_case("integer division by zero", R"SOURCE( | 1484 | add_debug_safety_case("integer division by zero", R"SOURCE( |
| | 1485 | error Whatever; |
| 1473 | pub fn main(args: [][]u8) -> %void { | 1486 | pub fn main(args: [][]u8) -> %void { |
| 1474 | div0(999, 0); | 1487 | const x = div0(999, 0); |
| 1475 | } | 1488 | } |
| 1476 | #static_eval_enable(false) | 1489 | #static_eval_enable(false) |
| 1477 | fn div0(a: i32, b: i32) -> i32 { | 1490 | fn div0(a: i32, b: i32) -> i32 { |
| ... | @@ -1480,8 +1493,10 @@ fn div0(a: i32, b: i32) -> i32 { | ... | @@ -1480,8 +1493,10 @@ fn div0(a: i32, b: i32) -> i32 { |
| 1480 | )SOURCE"); | 1493 | )SOURCE"); |
| 1481 | | 1494 | |
| 1482 | add_debug_safety_case("exact division failure", R"SOURCE( | 1495 | add_debug_safety_case("exact division failure", R"SOURCE( |
| | 1496 | error Whatever; |
| 1483 | pub fn main(args: [][]u8) -> %void { | 1497 | pub fn main(args: [][]u8) -> %void { |
| 1484 | div_exact(10, 3); | 1498 | const x = div_exact(10, 3); |
| | 1499 | if (x == 0) return error.Whatever; |
| 1485 | } | 1500 | } |
| 1486 | #static_eval_enable(false) | 1501 | #static_eval_enable(false) |
| 1487 | fn div_exact(a: i32, b: i32) -> i32 { | 1502 | fn div_exact(a: i32, b: i32) -> i32 { |
| ... | @@ -1490,8 +1505,10 @@ fn div_exact(a: i32, b: i32) -> i32 { | ... | @@ -1490,8 +1505,10 @@ fn div_exact(a: i32, b: i32) -> i32 { |
| 1490 | )SOURCE"); | 1505 | )SOURCE"); |
| 1491 | | 1506 | |
| 1492 | add_debug_safety_case("cast []u8 to bigger slice of wrong size", R"SOURCE( | 1507 | add_debug_safety_case("cast []u8 to bigger slice of wrong size", R"SOURCE( |
| | 1508 | error Whatever; |
| 1493 | pub fn main(args: [][]u8) -> %void { | 1509 | pub fn main(args: [][]u8) -> %void { |
| 1494 | widen_slice([]u8{1, 2, 3, 4, 5}); | 1510 | const x = widen_slice([]u8{1, 2, 3, 4, 5}); |
| | 1511 | if (x.len == 0) return error.Whatever; |
| 1495 | } | 1512 | } |
| 1496 | #static_eval_enable(false) | 1513 | #static_eval_enable(false) |
| 1497 | fn widen_slice(slice: []u8) -> []i32 { | 1514 | fn widen_slice(slice: []u8) -> []i32 { |
| ... | @@ -1500,8 +1517,10 @@ fn widen_slice(slice: []u8) -> []i32 { | ... | @@ -1500,8 +1517,10 @@ fn widen_slice(slice: []u8) -> []i32 { |
| 1500 | )SOURCE"); | 1517 | )SOURCE"); |
| 1501 | | 1518 | |
| 1502 | add_debug_safety_case("value does not fit in shortening cast", R"SOURCE( | 1519 | add_debug_safety_case("value does not fit in shortening cast", R"SOURCE( |
| | 1520 | error Whatever; |
| 1503 | pub fn main(args: [][]u8) -> %void { | 1521 | pub fn main(args: [][]u8) -> %void { |
| 1504 | shorten_cast(200); | 1522 | const x = shorten_cast(200); |
| | 1523 | if (x == 0) return error.Whatever; |
| 1505 | } | 1524 | } |
| 1506 | #static_eval_enable(false) | 1525 | #static_eval_enable(false) |
| 1507 | fn shorten_cast(x: i32) -> i8 { | 1526 | fn shorten_cast(x: i32) -> i8 { |
| ... | @@ -1510,8 +1529,10 @@ fn shorten_cast(x: i32) -> i8 { | ... | @@ -1510,8 +1529,10 @@ fn shorten_cast(x: i32) -> i8 { |
| 1510 | )SOURCE"); | 1529 | )SOURCE"); |
| 1511 | | 1530 | |
| 1512 | add_debug_safety_case("signed integer not fitting in cast to unsigned integer", R"SOURCE( | 1531 | add_debug_safety_case("signed integer not fitting in cast to unsigned integer", R"SOURCE( |
| | 1532 | error Whatever; |
| 1513 | pub fn main(args: [][]u8) -> %void { | 1533 | pub fn main(args: [][]u8) -> %void { |
| 1514 | unsigned_cast(-10); | 1534 | const x = unsigned_cast(-10); |
| | 1535 | if (x == 0) return error.Whatever; |
| 1515 | } | 1536 | } |
| 1516 | #static_eval_enable(false) | 1537 | #static_eval_enable(false) |
| 1517 | fn unsigned_cast(x: i32) -> u32 { | 1538 | fn unsigned_cast(x: i32) -> u32 { |