[clang-tools-extra] [clang-tidy] Warn on use of std::get_temporary_buffer (PR #176191)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 15 09:42:19 PST 2026


================
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy -std=c++17 %s bugprone-unsafe-functions %t --
+
+namespace std {
+template <class T1, class T2>
+struct pair {
+  T1 first;
+  T2 second;
+};
+
+using ptrdiff_t = long long;
+
+template<class T>
+std::pair<T*, std::ptrdiff_t>
+    get_temporary_buffer(std::ptrdiff_t count) noexcept;
+}
+
+void test() {
+  (void)std::get_temporary_buffer<int>(64);
+  // CHECK-MESSAGES:           :[[@LINE-1]]:9: warning: function 'get_temporary_buffer<int>' is bugprone, has no performance advantage, was deprecated in C++17 and removed in C++20; 'operator new[]' should be used instead
----------------
localspook wrote:

```suggestion
  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'get_temporary_buffer<int>' is bugprone, has no performance advantage, was deprecated in C++17 and removed in C++20; 'operator new[]' should be used instead
```

https://github.com/llvm/llvm-project/pull/176191


More information about the cfe-commits mailing list