2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wdangling-reference" }
4 // Don't warn for std::span-like classes.
11 [[nodiscard]] constexpr auto operator[](int n) const noexcept -> T& { return data_[n]; }
12 [[nodiscard]] constexpr auto front() const noexcept -> T& { return data_[0]; }
13 [[nodiscard]] constexpr auto back() const noexcept -> T& { return data_[len_ - 1]; }
16 auto get() -> Span<int>;
19 int const& a = get().front(); // { dg-bogus "dangling reference" }
20 int const& b = get().back(); // { dg-bogus "dangling reference" }
21 int const& c = get()[0]; // { dg-bogus "dangling reference" }