28 lines · cpp
1// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s2 3using size_t = decltype(sizeof(void *));4 5namespace std {6template <typename T> struct vector {7 T &operator[](size_t I);8};9 10struct string {11 const char *begin();12 const char *end();13};14 15} // namespace std16 17std::vector<std::string> getData();18 19void foo() {20 // Verifies we don't trigger a diagnostic from -Wdangling-gsl21 // when iterating over a temporary in C++23.22 for (auto c : getData()[0]) {23 (void)c;24 }25}26 27// expected-no-diagnostics28