diff --git a/src/cuda/rtc/compilation_output.hpp b/src/cuda/rtc/compilation_output.hpp index a0458f5f..e1a86cea 100644 --- a/src/cuda/rtc/compilation_output.hpp +++ b/src/cuda/rtc/compilation_output.hpp @@ -311,8 +311,14 @@ class compilation_output_base_t { dynarray log() const { size_t size = program::detail_::get_log_size(program_handle_, program_name_.c_str()); - dynarray result(size); + ::std::vector result(size+1); + if (size == 0) { return result; } program::detail_::get_log(result.data(), program_handle_, program_name_.c_str()); + // Q: Isn't it kind of "cheating" to use an ::std::vector, then return it as a dynarray? What + // if we get a proper dynarray which doesn't alias ::std::vector? + // A: Well, kind of; it would mean we might have to copy. However - a proper dynarray might + // allow us to construct it with an arbitrary buffer, or a larger dynarray etc. - and + // then we could ensure the allocation happens only once. return result; } ///@} @@ -399,6 +405,7 @@ class compilation_output_t : public compilation_output_base_t result(size); + if (size == 0) { return result; } program::detail_::get_ptx(result.data(), program_handle_, program_name_.c_str()); return result; } @@ -444,6 +451,7 @@ class compilation_output_t : public compilation_output_base_t(program_handle_, program_name_.c_str()); dynarray result(size); + if (size == 0) { return result; } program::detail_::get_cubin(result.data(), program_handle_, program_name_.c_str()); return result; } @@ -493,6 +501,7 @@ class compilation_output_t : public compilation_output_base_t result(size); + if (size == 0) { return result; } program::detail_::get_lto_ir(result.data(), program_handle_, program_name_.c_str()); return result; } @@ -584,6 +593,7 @@ class compilation_output_t : public compilation_output_base_t { { size_t size = program::detail_::get_cubin_size(program_handle_, program_name_.c_str()); dynarray result(size); + if (size == 0) { return result; } program::detail_::get_cubin(result.data(), program_handle_, program_name_.c_str()); return result; }