gcc/testsuite/g++.dg/warn/Wdangling-reference10.C
raw| 1 | // PR c++/107532 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | // { dg-options "-Wdangling-reference" } |
| 4 | // { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } } |
| 5 | |
| 6 | #include <span> |
| 7 | #include <vector> |
| 8 | |
| 9 | void f(const std::vector<int>& v) |
| 10 | { |
| 11 | const int& r = std::span<const int>(v)[0]; // { dg-bogus "dangling reference" } |
| 12 | (void) r; |
| 13 | } |