about summary refs log tree commit diff
path: root/tests/crashes/144293-indirect-ops-llvm.rs
blob: 490a0116d7d21b8496a778a97509cb15f49a1879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//@ known-bug: #144293
// Same as recursion-etc but eggs LLVM emission into giving indirect arguments.
#![expect(incomplete_features)]
#![feature(explicit_tail_calls)]

use std::hint::black_box;

struct U64Wrapper {
    pub x: u64,
    pub arbitrary: String,
}

fn count(curr: U64Wrapper, top: U64Wrapper) -> U64Wrapper {
    if black_box(curr.x) >= top.x {
        curr
    } else {
        become count(
            U64Wrapper {
                x: curr.x + 1,
                arbitrary: curr.arbitrary,
            },
            top,
        )
    }
}

fn main() {
    println!(
        "{}",
        count(
            U64Wrapper {
                x: 0,
                arbitrary: "hello!".into()
            },
            black_box(U64Wrapper {
                x: 1000000,
                arbitrary: "goodbye!".into()
            })
        )
        .x
    );
}