From 058be6c6e9c7244df97d090329e68281d2a756a7 Mon Sep 17 00:00:00 2001 From: John Shumway Date: Tue, 17 Feb 2026 17:26:32 -0800 Subject: [PATCH] [CK_BUILDER] Fix two staging-compiler errors in CK builder code (#4598) This PR fixes two compiler warnings that report as errors with the latest compiler: 1. In tensor descriptor, the `operator[]` accessor needs a `[[clang::lifetimebound]]` attribute. 2. In the unit tests for device buffer, there is a test that explicitly checks for an error on a pointer that went out of scope, so it needs a to disable `-Wlifetime-safety-permissive` in the test code. I ran the CK `smoke-builder` tests with the staging compiler to verify. --------- Co-authored-by: illsilin_amdeng --- .../include/ck_tile/builder/testing/tensor_descriptor.hpp | 5 +++-- experimental/builder/test/unit_device_buffer.cpp | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/experimental/builder/include/ck_tile/builder/testing/tensor_descriptor.hpp b/experimental/builder/include/ck_tile/builder/testing/tensor_descriptor.hpp index 6a150a0233..0b1ebb69b8 100644 --- a/experimental/builder/include/ck_tile/builder/testing/tensor_descriptor.hpp +++ b/experimental/builder/include/ck_tile/builder/testing/tensor_descriptor.hpp @@ -106,7 +106,7 @@ struct Extent : std::array /// @param i The index to index the array with. /// /// @see std::array::operator[] - __device__ __host__ size_t& operator[](size_t i) + __device__ __host__ size_t& operator[](size_t i) [[clang::lifetimebound]] { if constexpr(RANK > 0) { @@ -450,7 +450,8 @@ struct TensorDescriptor /// @brief Print tensor descriptor details. /// /// Print tensor descriptor details - lengths and strides. - friend std::ostream& operator<<(std::ostream& os, const TensorDescriptor& tensor_desc) + friend std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os, + const TensorDescriptor& tensor_desc) { os << tensor_desc.inner_descriptor_; return os; diff --git a/experimental/builder/test/unit_device_buffer.cpp b/experimental/builder/test/unit_device_buffer.cpp index 548b055238..c26a03a54f 100644 --- a/experimental/builder/test/unit_device_buffer.cpp +++ b/experimental/builder/test/unit_device_buffer.cpp @@ -48,6 +48,10 @@ TEST(DeviceBuffer, AutoFree) const auto size = 12345; std::byte* ptr = nullptr; + // In this test we are explicitly testing a pointer that is out of scope, so + // we have to disable the clang compiler's lifestime safety checks. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wlifetime-safety-permissive" { auto buffer = ckt::alloc_buffer(size); ptr = buffer.get(); @@ -55,6 +59,7 @@ TEST(DeviceBuffer, AutoFree) // Trying to use a pointer after freeing should return en error in HIP. EXPECT_THAT(hipMemset(ptr, 0xFF, size), HipError(hipErrorInvalidValue)); +#pragma clang diagnostic pop // Reset internal HIP error state. // Otherwise, the error may leak into other tests, triggering anything that