From acd964309dd41b95c81d63fd5a480797d76a4ed2 Mon Sep 17 00:00:00 2001 From: Urs Ganse Date: Wed, 3 May 2023 15:07:44 +0300 Subject: [PATCH] Patch for undefined behaviour (nullpointer reference). Discovered by GCC12's undefined behaviour sanitizer. --- dccrg_mpi_support.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dccrg_mpi_support.hpp b/dccrg_mpi_support.hpp index fe7a5d2..96f2af7 100644 --- a/dccrg_mpi_support.hpp +++ b/dccrg_mpi_support.hpp @@ -185,6 +185,10 @@ class All_Gather total_send_count += (uint64_t) send_count; } + if(total_send_count == 0) { + //Early abort if there is nothing to communicate. + return; + } std::vector temp_result(total_send_count, std::numeric_limits::max()); // give a sane address to gatherv also when nothing to send