summaryrefslogtreecommitdiffhomepage
path: root/CompilerDriver/cc2/regression-tests/mixed-bounds-safety-with-assert.cpp2
blob: dc9fba07cc0fb038027590cf4e2d9e576ccbc442 (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

main: () -> int = {
    std::set_terminate(std::abort);

    v: std::vector<int> = (1, 2, 3, 4, 5);
    print_subrange(v, 1, 13);
}

print_subrange: (rng:_, start:int, end:int) = {
    assert<Bounds>( 0 <= start );
    assert<Bounds>( end <= rng.ssize() );

    count := 0;
    for  rng
    next count++
    do   (i)
        if start <= count && count <= end {
            std::cout << i << "\n";
        }
}

#include <vector>
#include <span>
#include <iostream>