Skip to content

Commit

Permalink
🚨 Fixing erroneous GCC warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBreugnot committed Jul 12, 2023
1 parent b917082 commit 318e54b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@ project(chemmisol VERSION 0.1)
# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)

set(CHEMMISOL_MEMORY_SANITIZE NO CACHE BOOL "Enables -fsanitize=address.")

set(CMAKE_CXX_FLAGS_DEBUG "\
${CMAKE_CXX_FLAGS_DEBUG} -std=c++14 \
-Wall -Wextra -Wpedantic -Werror -Wno-error=pedantic \
-Wall -Wextra -Wpedantic -Wno-error=pedantic \
-Woverloaded-virtual -Wnon-virtual-dtor \
-fsanitize=address \
-Wno-range-loop-construct \
")
if(CHEMMISOL_MEMORY_SANITIZE)
message(STATUS "Enabling -fsanitize=address")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
endif()

set(CHEMMISOL_LOCAL_EASYLOGGING "" CACHE PATH
"Path to easylogging++ sources. If not specified, sources will be downloaded at configure time."
)

if($<CONFIG:Debug>$)
message(STATUS "DEBUG")
endif()
if($<CONFIG:Release>$)
message(STATUS "RELEASE")
endif()

if(CHEMMISOL_LOCAL_EASYLOGGING)
set(EASYLOGGING_SRC_PATH ${CHEMMISOL_LOCAL_EASYLOGGING})
else()
Expand Down
8 changes: 6 additions & 2 deletions src/chemmisol/chemical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ namespace chemmisol {
break;
case SOLVENT:
fixed_component = new Solvent(name, index);
break;
default:
// Should not append
fixed_component = nullptr;
}
components[index].reset(fixed_component);
existing_component->second = fixed_component;
Expand Down Expand Up @@ -347,7 +351,7 @@ namespace chemmisol {
// The limiting reactive is used to define the maximum possible
// extent of the reaction so that all reagent concentrations stay
// positive.
const Component* limiting_reactive;
const Component* limiting_reactive = nullptr;
double limiting_reactive_coefficient = 0;
double smallest_limiting_factor = std::numeric_limits<double>::infinity();

Expand Down Expand Up @@ -375,7 +379,7 @@ namespace chemmisol {
GuessF f = GuessF(*this, *reaction, guessed_concentrations);

double max_N;
if(smallest_limiting_factor < std::numeric_limits<double>::infinity()) {
if(limiting_reactive != nullptr) {
CHEM_LOG(DEBUG) << " Limiting reactive: " << limiting_reactive_coefficient
<< " " << limiting_reactive->getName() << " " <<
limiting_reactive_coefficient * smallest_limiting_factor << " mol/l";
Expand Down

0 comments on commit 318e54b

Please sign in to comment.