diff --git a/cpp/src/nvtx.cpp b/cpp/src/nvtx.cpp index b9d7c3e146..0467e46e38 100644 --- a/cpp/src/nvtx.cpp +++ b/cpp/src/nvtx.cpp @@ -85,7 +85,8 @@ void NvtxManager::rename_current_thread(std::string_view new_name) noexcept attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE; attribs.identifier.ullValue = tid; attribs.messageType = NVTX_MESSAGE_TYPE_ASCII; - attribs.message.ascii = ss.str().c_str(); + auto st = ss.str(); + attribs.message.ascii = st.c_str(); nvtxResourceHandle_t handle = nvtxDomainResourceCreate(nvtx3::domain::get(), &attribs); #endif