[clang] [Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (PR #145164)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 25 10:38:18 PDT 2025
================
@@ -0,0 +1,79 @@
+// RUN: %clangxx -std=c++23 -fsyntax-only -Xclang -verify %s
+
+#include <string>
+#include <vector>
+#include <map>
+#include <tuple>
+#include <optional>
+#include <variant>
+#include <array>
+#include <span>
----------------
yronglin wrote:
I have a more simple reproducer:
```cpp
using size_t = decltype(sizeof(void *));
namespace std {
template <typename T> struct vector {
T &operator[](size_t I);
};
struct string {
const char *begin();
const char *end();
};
} // namespace std
extern "C" int printf(const char *, ...);
std::vector<std::string> getData();
void foo() {
for (auto c : getData()[0]) {
printf("%c\n", c);
}
}
```
https://github.com/llvm/llvm-project/pull/145164
More information about the cfe-commits
mailing list