Skip to content

Commit

Permalink
Fix GCC 12 & 13 warnings on null-dereference (AMReX-Codes#4171)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang authored Sep 30, 2024
1 parent 103d0e9 commit ea4eb97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Build & Install
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -O1 -Wnon-virtual-dtor -Wlogical-op -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wmissing-include-dirs -Wno-null-dereference"}
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -O1 -Wnon-virtual-dtor -Wlogical-op -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wmissing-include-dirs"}
# It's too slow with -O0
run: |
export CCACHE_COMPRESS=1
Expand Down Expand Up @@ -353,10 +353,7 @@ jobs:
# /home/runner/work/amrex/amrex/Src/Base/AMReX_IntVect.H:194:92: error: array subscript -1 is below array bounds of ‘int [3]’ [-Werror=array-bounds]
# int& operator[] (int i) noexcept { BL_ASSERT(i>=0 && i < AMREX_SPACEDIM); return vect[i]; }
#
# inlined from ‘const amrex::MultiFab& amrex::EBFArrayBoxFactory::getVolFrac() const’ at /home/runner/work/amrex/amrex/Src/EB/AMReX_EBFabFactory.H:53:91,
# /usr/include/c++/12/bits/shared_ptr_base.h:1666:16: error: potential null pointer dereference [-Werror=null-dereference]
#
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wunreachable-code -Wnon-virtual-dtor -Wlogical-op -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wmissing-include-dirs -Wno-array-bounds -Wno-null-dereference"}
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wunreachable-code -Wnon-virtual-dtor -Wlogical-op -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wmissing-include-dirs -Wno-array-bounds"}
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
Expand All @@ -377,7 +374,6 @@ jobs:
-DAMReX_EB=ON \
-DAMReX_ENABLE_TESTS=ON \
-DAMReX_FORTRAN=OFF \
-DAMReX_FORTRAN=OFF \
-DCMAKE_C_COMPILER=$(which gcc-12) \
-DCMAKE_CXX_COMPILER=$(which g++-12) \
-DCMAKE_CXX_STANDARD=17 \
Expand Down
4 changes: 2 additions & 2 deletions Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H
Original file line number Diff line number Diff line change
Expand Up @@ -2009,11 +2009,11 @@ MLCellLinOpT<MF>::normInf (int amrlev, MF const& mf, bool local) const -> RT
const int finest_level = this->NAMRLevels() - 1;
RT norm = RT(0.0);
#ifdef AMREX_USE_EB
if (! mf.isAllRegular()) {
const auto *factory = dynamic_cast<EBFArrayBoxFactory const*>(this->Factory(amrlev));
if (factory && !factory->isAllRegular()) {
if constexpr (!std::is_same<MF,MultiFab>()) {
amrex::Abort("MLCellLinOpT with EB only works with MultiFab");
} else {
const auto *factory = dynamic_cast<EBFArrayBoxFactory const*>(this->Factory(amrlev));
const MultiFab& vfrac = factory->getVolFrac();
if (amrlev == finest_level) {
#ifdef AMREX_USE_GPU
Expand Down

0 comments on commit ea4eb97

Please sign in to comment.