Debian Codegraph @

gcc/testsuite/g++.dg/pr99966.C

raw
1 // { dg-do compile }
2 // { dg-require-effective-target c++17 }
3 // { dg-options "-O2 -fdump-tree-vrp1" }
4 // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
5
6 // Test we can remove a range bound after the assert.
7
8 #include <cassert>
9 #include <cstdint>
10 #include <cstddef>
11 #include <vector>
12
13 uint64_t f(std::vector<uint64_t>& data, size_t start, size_t end){
14 assert(start < end && start < data.size() && end <= data.size());
15
16
17 uint64_t total = 0;
18 for (size_t i = start; i < end; i++) {
19 total += data.at(i);
20 }
21 return total;
22 }
23
24 /* { dg-final { scan-tree-dump-not "throw" "vrp1" { xfail hppa*64*-*-* } } } */