From: Martin Kronbichler Date: Thu, 20 Nov 2014 14:47:24 +0000 (+0100) Subject: Third attempt to fix uninitialized variable in MPI::MinMaxAvg X-Git-Tag: v8.2.0-rc1~53^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b27ce1ea2227e170aab8c2ec3c94745bb9b882f;p=dealii.git Third attempt to fix uninitialized variable in MPI::MinMaxAvg --- diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 75a5667f2f..da8b667f4d 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -216,8 +216,8 @@ namespace Utilities */ struct MinMaxAvg { - MinMaxAvg(); - + // Note: We assume a POD property of this struct in the MPI calls in + // min_max_avg double sum; double min; double max; diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 3fc0077a91..c1bce6890e 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -230,7 +230,11 @@ namespace Utilities min_max_avg(const double my_value, const MPI_Comm &mpi_communicator) { - MinMaxAvg result; + // To avoid uninitialized values on some MPI implementations, provide + // result with a default value already... + MinMaxAvg result = { 0., std::numeric_limits::max(), + -std::numeric_limits::max(), 0, 0, 0. + }; const unsigned int my_id = dealii::Utilities::MPI::this_mpi_process(mpi_communicator); @@ -310,18 +314,6 @@ namespace Utilities - MinMaxAvg::MinMaxAvg () - : - sum (0.), - min (std::numeric_limits::max()), - max (-min), - min_index (0), - max_index (0), - avg (0) - {} - - - MPI_InitFinalize::MPI_InitFinalize (int &argc, char ** &argv, const unsigned int max_num_threads)