From 308af391368b2b1ef6b1e5fc9d2a959336527f0c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 26 Apr 2021 17:07:41 +0200 Subject: [PATCH 1/2] COMP: sign check to avoid warnings about new[] range --- src/OpenFOAM/containers/Lists/List/List.C | 1 + src/OpenFOAM/containers/Lists/List/ListI.H | 3 ++- src/OpenFOAM/matrices/Matrix/MatrixI.H | 3 ++- wmake/rules/linux64Mingw/c++ | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 302529f81f..68f0c6440b 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -50,6 +50,7 @@ void Foam::List::doResize(const label newSize) { if (newSize > 0) { + // With sign-check to avoid spurious -Walloc-size-larger-than T* nv = new T[newSize]; const label overlap = min(this->size_, newSize); diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H index a7b0aca30c..650afea8c1 100644 --- a/src/OpenFOAM/containers/Lists/List/ListI.H +++ b/src/OpenFOAM/containers/Lists/List/ListI.H @@ -31,8 +31,9 @@ License template inline void Foam::List::doAlloc() { - if (this->size_) + if (this->size_ > 0) { + // With sign-check to avoid spurious -Walloc-size-larger-than this->v_ = new T[this->size_]; } } diff --git a/src/OpenFOAM/matrices/Matrix/MatrixI.H b/src/OpenFOAM/matrices/Matrix/MatrixI.H index 6d96f4c0e4..2dc069a6f5 100644 --- a/src/OpenFOAM/matrices/Matrix/MatrixI.H +++ b/src/OpenFOAM/matrices/Matrix/MatrixI.H @@ -35,8 +35,9 @@ inline void Foam::Matrix::doAlloc() { const label len = size(); - if (len) + if (len > 0) { + // With sign-check to avoid spurious -Walloc-size-larger-than v_ = new Type[len]; } } diff --git a/wmake/rules/linux64Mingw/c++ b/wmake/rules/linux64Mingw/c++ index aebb7a8831..4aad393721 100644 --- a/wmake/rules/linux64Mingw/c++ +++ b/wmake/rules/linux64Mingw/c++ @@ -9,7 +9,7 @@ include $(RULES)/c++$(WM_COMPILE_OPTION) c++FLAGS = $(c++ARCH) $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -Wno-alloc-size-larger-than -c $< -o $@ +Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@ cxxtoo = $(Ctoo) cctoo = $(Ctoo) cpptoo = $(Ctoo) From 3b29395a666ec5a48ee61cd3227b439e9cdae73e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 18 Jun 2021 15:45:00 +0200 Subject: [PATCH 2/2] BUG: surfaceFieldValue with vectorWeights blocks in parallel (fixes #2129) --- META-INFO/api-info | 2 +- .../field/fieldValues/surfaceFieldValue/surfaceFieldValue.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/META-INFO/api-info b/META-INFO/api-info index cd9bb8d075..f822bdb37d 100644 --- a/META-INFO/api-info +++ b/META-INFO/api-info @@ -1,2 +1,2 @@ api=2012 -patch=210414 +patch=210618 diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 6b1684577b..dbc4f0c315 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -1263,7 +1263,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write() // Process the fields - if (vectorWeights.size()) + if (returnReduce(!vectorWeights.empty(), orOp())) { if (scalarWeights.size()) {