[clang] [Clang] Fix deleted C++20 destructor call in GPU header (PR #214837)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 09:56:02 PDT 2026


================
@@ -61,11 +61,16 @@ __GPU_COORD_BUILTIN(__gpu_builtin_gridDim_t, __gpu_num_blocks_x(),
 #pragma pop_macro("__GPU_COORD_BUILTIN")
 #pragma pop_macro("__GPU_DISALLOW_BUILTINVAR_ACCESS")
 
-static inline const
-    __attribute__((device)) __gpu_builtin_threadIdx_t threadIdx{};
-static inline const __attribute__((device)) __gpu_builtin_blockIdx_t blockIdx{};
-static inline const __attribute__((device)) __gpu_builtin_blockDim_t blockDim{};
-static inline const __attribute__((device)) __gpu_builtin_gridDim_t gridDim{};
+#pragma push_macro("__GPU_BUILTIN_VAR")
+#define __GPU_BUILTIN_VAR                                                      \
+  extern const __attribute__((device)) __attribute__((weak))
+
+__GPU_BUILTIN_VAR __gpu_builtin_threadIdx_t threadIdx;
----------------
jhuber6 wrote:

`extern const` is different from normal `extern`, they are defined but get a linkable symbol.

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


More information about the cfe-commits mailing list