summaryrefslogtreecommitdiffhomepage
path: root/CompilerDriver/cc2/regression-tests/mixed-lifetime-safety-pointer-init-4.cpp2
blob: b2ed5ffdb2f8f0c0b77d802143d4ebce5ed8d354 (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

#include <iostream>
#include <random>

main: () -> int = {
    x: int = 42;
    y: int = 43;
    p: *int;

    // ... more code ...
    if flip_a_coin() {
        p = y&;
    }
    else {
        p = x&;
    }

    print_and_decorate( p* );
}

print_and_decorate: (thing:_) =
    std::cout << ">> " << thing << "\n";

bool flip_a_coin() {
    // Change std::mt19937 to std::random_device for non-deterministic PRNG
    static std::mt19937 rand; 
    return rand() % 2 == 1;
}