Two unreachable code sections
Clang 12 warns about two code section, which are not reachable. Often, this is a sign that the code behaves different from what the programmer expected. In other words, it could be a bug or it could be some overcautious code.
Do you mind having a look?
[ 30%] Building CXX object test/material/fluidsystems/CMakeFiles/test_fluidsystems.dir/test_fluidsystems.cc.o
In file included from /usr/include/c++/11/cassert:44,
from /home/gruenich/dune/complete/dune-common/dune/common/parallel/mpihelper.hh:7,
from /home/gruenich/dune/complete/dumux/dumux/common/parameters.hh:36,
from /home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh:31,
from /home/gruenich/dune/complete/dumux/test/material/fluidsystems/checkfluidsystem.hh:40,
from /home/gruenich/dune/complete/dumux/test/material/fluidsystems/test_fluidsystems.cc:28:
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh: In static member function ‘static constexpr int Dumux::FluidSystems::BrineCO2<Scalar, CO2Table, H2OType, Policy>::BrineAdapterPolicy::compIdx(int) [with Scalar = double; CO2Table = Dumux::HeterogeneousCO2Tables::CO2Tables; H2OType = Dumux::Components::SimpleH2O<double>; Policy = Dumux::FluidSystems::BrineCO2DefaultPolicy<false>]’:
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh:181:70: warning: statement will never be executed [-Wswitch-unreachable]
181 | assert(brineCompIdx == VariableSalinityBrine::H2OIdx || brineCompIdx == VariableSalinityBrine::NaClIdx);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh: In static member function ‘static constexpr int Dumux::FluidSystems::BrineCO2<Scalar, CO2Table, H2OType, Policy>::BrineAdapterPolicy::compIdx(int) [with Scalar = double; CO2Table = Dumux::HeterogeneousCO2Tables::CO2Tables; H2OType = Dumux::Components::H2O<double>; Policy = Dumux::FluidSystems::BrineCO2DefaultPolicy<false>]’:
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh:181:70: warning: statement will never be executed [-Wswitch-unreachable]
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh: In static member function ‘static constexpr int Dumux::FluidSystems::BrineCO2<Scalar, CO2Table, H2OType, Policy>::BrineAdapterPolicy::compIdx(int) [with Scalar = double; CO2Table = Dumux::HeterogeneousCO2Tables::CO2Tables; H2OType = Dumux::Components::TabulatedComponent<Dumux::Components::H2O<double>, true>; Policy = Dumux::FluidSystems::BrineCO2DefaultPolicy<false>]’:
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh:181:70: warning: statement will never be executed [-Wswitch-unreachable]
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh: In static member function ‘static constexpr int Dumux::FluidSystems::BrineCO2<Scalar, CO2Table, H2OType, Policy>::BrineAdapterPolicy::compIdx(int) [with Scalar = double; CO2Table = Dumux::HeterogeneousCO2Tables::CO2Tables; H2OType = Dumux::Components::TabulatedComponent<Dumux::Components::H2O<double>, true>; Policy = Dumux::FluidSystems::BrineCO2DefaultPolicy<false, true>]’:
/home/gruenich/dune/complete/dumux/dumux/material/fluidsystems/brineco2.hh:181:70: warning: statement will never be executed [-Wswitch-unreachable]
[ 99%] Building CXX object examples/shallowwaterfriction/CMakeFiles/example_shallowwaterfriction.dir/main.cc.o
In file included from /home/gruenich/dune/complete/dumux/examples/biomineralization/material/fluidsystems/biominsimplechemistry.hh:62,
from /home/gruenich/dune/complete/dumux/examples/biomineralization/properties.hh:48,
from /home/gruenich/dune/complete/dumux/examples/biomineralization/main.cc:57:
/home/gruenich/dune/complete/dumux/examples/biomineralization/material/fluidsystems/biominsimplechemistry.hh: In static member function ‘static constexpr int Dumux::FluidSystems::BioMinSimpleChemistryFluid<Scalar, CO2Table, H2OType>::BrineAdapterPolicy::compIdx(int) [with Scalar = double; CO2Table = Dumux::ICP::CO2Tables; H2OType = Dumux::Components::TabulatedComponent<Dumux::Components::H2O<double>, true>]’:
/home/gruenich/dune/complete/dumux/examples/biomineralization/material/fluidsystems/biominsimplechemistry.hh:236:25: warning: statement will never be executed [-Wswitch-unreachable]
233 | assert(brineCompIdx == Brine::H2OIdx
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
234 | || brineCompIdx == Brine::NaIdx
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235 | || brineCompIdx == Brine::ClIdx
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
236 | || brineCompIdx == Brine::CaIdx
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~