(root)/
gcc-13.2.0/
gcc/
testsuite/
g++.dg/
warn/
Wdangling-reference4.C
// { dg-do compile { target c++17 } }
// { dg-options "-Wdangling-reference" }
// Check that we warn here even without -Wsystem-headers.

#include <optional>
#include <string>

auto f() -> std::optional<std::string>;

void
g ()
{
  for (char c : f().value()) { (void) c; } // { dg-warning "dangling reference" }
}