mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 20:01:22 -05:00
gccrs: testsuite: add loop condition execution test
gcc/testsuite/ChangeLog: * rust/execute/torture/loop-condition-eval.rs: New test. Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
This commit is contained in:
21
gcc/testsuite/rust/execute/torture/loop-condition-eval.rs
Normal file
21
gcc/testsuite/rust/execute/torture/loop-condition-eval.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
// { dg-output "1\n" }
|
||||
pub fn test() -> u64 {
|
||||
let mut n = 113383; // #20 in https://oeis.org/A006884
|
||||
while n != 1 {
|
||||
n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 };
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
pub fn test_1() -> u64 {
|
||||
test()
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn printf(fmt: *const i8, ...);
|
||||
}
|
||||
|
||||
fn main() -> i32 {
|
||||
unsafe { printf("%lu\n" as *const str as *const i8, test_1()) }
|
||||
0
|
||||
}
|
||||
Reference in New Issue
Block a user