From 496611320d7ecd0bd55924065ec56d956f7d004c Mon Sep 17 00:00:00 2001 From: Eyal Rozenberg Date: Fri, 22 Jul 2022 19:40:07 +0300 Subject: [PATCH] Fixes #378: Chop trailing `'\0'` from the compilation log. --- src/cuda/nvrtc/compilation_output.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cuda/nvrtc/compilation_output.hpp b/src/cuda/nvrtc/compilation_output.hpp index a4de97fd..c10290d3 100644 --- a/src/cuda/nvrtc/compilation_output.hpp +++ b/src/cuda/nvrtc/compilation_output.hpp @@ -142,14 +142,15 @@ class compilation_output_t { */ dynarray log() const { - size_t size; - auto status = nvrtcGetProgramLogSize(program_handle_, &size); - throw_if_error(status, "Failed obtaining compilation log size for " + size_t size_including_trailing_null; + auto status = nvrtcGetProgramLogSize(program_handle_, &size_including_trailing_null); + throw_if_error(status, "Failed obtaining compilation log size_including_trailing_null for " + compilation_output::detail_::identify(*this)); - dynarray result(size); + ::std::vector result(size_including_trailing_null); status = nvrtcGetProgramLog(program_handle_, result.data()); throw_if_error(status, "Failed obtaining compilation log for" + compilation_output::detail_::identify(*this)); + result.resize(size_including_trailing_null - 1); return result; }