blob: 59b5538aee59bf7c3cff1d0d740c0e7c0b6c89a5 [file] [log] [blame]
// PR c++/107488
// { dg-do compile }
// { dg-options "-Wdangling-reference" }
#include <vector>
int
do_sum (std::vector<int>& v)
{
int sum = 0;
std::vector<int>::const_iterator it = v.begin();
while (it != v.end())
{
// R refers to one of the int elements of V, not to a temporary
// object, so no dangling reference here.
const int &r = *it++; // { dg-bogus "dangling reference" }
sum += r;
}
return sum;
}