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

main: () -> int = {
    v: std::vector<int> = (1, 2, 3, 4, 5);
    add_42_to_subrange(v, 1, 3);

    for v do (i)
        std::cout << i << "\n";
}

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

    count := 0;
    for  rng
    next count++
    do   (inout i)
        if start <= count <= end {
            i += 42;
        }
}

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