diff --git a/src/cmake_modules/FastDownwardMacros.cmake b/src/cmake_modules/FastDownwardMacros.cmake index 3ad1b980c8..3e5f4bfe35 100644 --- a/src/cmake_modules/FastDownwardMacros.cmake +++ b/src/cmake_modules/FastDownwardMacros.cmake @@ -18,7 +18,7 @@ macro(fast_downward_set_compiler_flags) check_and_set_compiler_flag( "-std=c++20" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Wfloat-conversion -Wmissing-declarations") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Wfloat-conversion -Wmissing-declarations -Wzero-as-null-pointer-constant") if (CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12 diff --git a/src/search/heuristics/cea_heuristic.cc b/src/search/heuristics/cea_heuristic.cc index f0f9e0b912..da05b84f7d 100644 --- a/src/search/heuristics/cea_heuristic.cc +++ b/src/search/heuristics/cea_heuristic.cc @@ -98,7 +98,7 @@ struct LocalProblemNode { cost(-1), expanded(false), context(context_size, -1), - reached_by(0) { + reached_by(nullptr) { } ~LocalProblemNode() { @@ -222,7 +222,7 @@ void ContextEnhancedAdditiveHeuristic::set_up_local_problem( to_node.expanded = false; to_node.cost = numeric_limits::max(); to_node.waiting_list.clear(); - to_node.reached_by = 0; + to_node.reached_by = nullptr; } LocalProblemNode *start = &problem->nodes[start_value]; @@ -359,7 +359,7 @@ void ContextEnhancedAdditiveHeuristic::mark_helpful_transitions( assert(node->cost >= 0 && node->cost < numeric_limits::max()); LocalTransition *first_on_path = node->reached_by; if (first_on_path) { - node->reached_by = 0; // Clear to avoid revisiting this node later. + node->reached_by = nullptr; // Clear to avoid revisiting this node later. if (first_on_path->target_cost == first_on_path->action_cost) { // Transition possibly applicable. const ValueTransitionLabel &label = *first_on_path->label; @@ -425,7 +425,7 @@ ContextEnhancedAdditiveHeuristic::ContextEnhancedAdditiveHeuristic( VariablesProxy vars = task_proxy.get_variables(); local_problem_index.resize(vars.size()); for (VariableProxy var : vars) - local_problem_index[var.get_id()].resize(var.get_domain_size(), 0); + local_problem_index[var.get_id()].resize(var.get_domain_size(), nullptr); } ContextEnhancedAdditiveHeuristic::~ContextEnhancedAdditiveHeuristic() { diff --git a/src/search/heuristics/cg_heuristic.cc b/src/search/heuristics/cg_heuristic.cc index 0fd4fbf3d1..6b491451c2 100644 --- a/src/search/heuristics/cg_heuristic.cc +++ b/src/search/heuristics/cg_heuristic.cc @@ -105,10 +105,10 @@ int CGHeuristic::get_transition_cost(const State &state, if (start->distances.empty()) { // Initialize data of initial node. start->distances.resize(dtg->nodes.size(), numeric_limits::max()); - start->helpful_transitions.resize(dtg->nodes.size(), 0); + start->helpful_transitions.resize(dtg->nodes.size(), nullptr); start->distances[start_val] = 0; - start->reached_from = 0; - start->reached_by = 0; + start->reached_from = nullptr; + start->reached_by = nullptr; start->children_state.resize(dtg->local_to_global_child.size()); for (size_t i = 0; i < dtg->local_to_global_child.size(); ++i) { start->children_state[i] = @@ -188,7 +188,7 @@ int CGHeuristic::get_transition_cost(const State &state, target->reached_from = source; target->reached_by = &label; - if (current_helpful_transition == 0) { + if (current_helpful_transition == nullptr) { // This transition starts at the start node; // no helpful transitions recorded yet. start->helpful_transitions[target->value] = &label; diff --git a/src/search/heuristics/domain_transition_graph.h b/src/search/heuristics/domain_transition_graph.h index bce9fd8c8e..14529850c0 100644 --- a/src/search/heuristics/domain_transition_graph.h +++ b/src/search/heuristics/domain_transition_graph.h @@ -111,7 +111,8 @@ struct ValueNode { ValueTransitionLabel *reached_by; ValueNode(DomainTransitionGraph *parent, int val) - : parent_graph(parent), value(val), reached_from(0), reached_by(0) {} + : parent_graph(parent), value(val), reached_from(nullptr), + reached_by(nullptr) {} }; class DomainTransitionGraph { diff --git a/src/search/heuristics/lm_cut_landmarks.cc b/src/search/heuristics/lm_cut_landmarks.cc index 5bbae3bfe2..71c7602a8d 100644 --- a/src/search/heuristics/lm_cut_landmarks.cc +++ b/src/search/heuristics/lm_cut_landmarks.cc @@ -102,7 +102,7 @@ void LandmarkCutLandmarks::setup_exploration_queue() { for (RelaxedOperator &op : relaxed_operators) { op.unsatisfied_preconditions = op.preconditions.size(); - op.h_max_supporter = 0; + op.h_max_supporter = nullptr; op.h_max_supporter_cost = numeric_limits::max(); } } diff --git a/src/search/landmarks/landmark_factory_merged.cc b/src/search/landmarks/landmark_factory_merged.cc index 01f8b05b25..db3fd9b465 100644 --- a/src/search/landmarks/landmark_factory_merged.cc +++ b/src/search/landmarks/landmark_factory_merged.cc @@ -24,18 +24,18 @@ LandmarkNode *LandmarkFactoryMerged::get_matching_landmark(const Landmark &landm if (lm_graph->contains_simple_landmark(lm_fact)) return &lm_graph->get_simple_landmark(lm_fact); else - return 0; + return nullptr; } else if (landmark.disjunctive) { set lm_facts(landmark.facts.begin(), landmark.facts.end()); if (lm_graph->contains_identical_disjunctive_landmark(lm_facts)) return &lm_graph->get_disjunctive_landmark(landmark.facts[0]); else - return 0; + return nullptr; } else if (landmark.conjunctive) { cerr << "Don't know how to handle conjunctive landmarks yet" << endl; utils::exit_with(ExitCode::SEARCH_UNSUPPORTED); } - return 0; + return nullptr; } void LandmarkFactoryMerged::generate_landmarks( diff --git a/src/search/lp/soplex_solver_interface.h b/src/search/lp/soplex_solver_interface.h index 7eeeefb19d..839561758a 100644 --- a/src/search/lp/soplex_solver_interface.h +++ b/src/search/lp/soplex_solver_interface.h @@ -8,6 +8,7 @@ #ifdef __GNUG__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #if (__GNUG__ >= 11) || (__clang_major__ >= 12) #pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion" #endif diff --git a/src/search/pdbs/match_tree.cc b/src/search/pdbs/match_tree.cc index 64b1059be0..20b3fa6d58 100644 --- a/src/search/pdbs/match_tree.cc +++ b/src/search/pdbs/match_tree.cc @@ -78,7 +78,7 @@ MatchTree::~MatchTree() { void MatchTree::insert_recursive( int op_id, const vector ®ression_preconditions, int pre_index, Node **edge_from_parent) { - if (*edge_from_parent == 0) { + if (*edge_from_parent == nullptr) { // We don't exist yet: create a new node. *edge_from_parent = new Node(); } @@ -111,7 +111,7 @@ void MatchTree::insert_recursive( /* Set up edge to the correct child (for which we want to call this function recursively). */ - Node **edge_to_child = 0; + Node **edge_to_child = nullptr; if (node->var_id == fact.var) { // Operator has a precondition on the variable tested by node. edge_to_child = &node->successors[fact.value]; diff --git a/src/search/pdbs/pattern_collection_generator_hillclimbing.cc b/src/search/pdbs/pattern_collection_generator_hillclimbing.cc index 7a38cc170c..74609dc173 100644 --- a/src/search/pdbs/pattern_collection_generator_hillclimbing.cc +++ b/src/search/pdbs/pattern_collection_generator_hillclimbing.cc @@ -121,7 +121,7 @@ PatternCollectionGeneratorHillclimbing::PatternCollectionGeneratorHillclimbing(c max_time(opts.get("max_time")), rng(utils::parse_rng_from_options(opts)), num_rejected(0), - hill_climbing_timer(0) { + hill_climbing_timer(nullptr) { } int PatternCollectionGeneratorHillclimbing::generate_candidate_pdbs( diff --git a/src/search/utils/system_unix.cc b/src/search/utils/system_unix.cc index 3d4eeb4611..6752d08b62 100644 --- a/src/search/utils/system_unix.cc +++ b/src/search/utils/system_unix.cc @@ -227,7 +227,7 @@ void register_event_handlers() { // On exit or when receiving certain signals such as SIGINT (Ctrl-C), // print the peak memory usage. #if OPERATING_SYSTEM == LINUX - on_exit(exit_handler, 0); + on_exit(exit_handler, nullptr); #elif OPERATING_SYSTEM == OSX atexit(exit_handler); #endif @@ -243,11 +243,11 @@ void register_event_handlers() { // Reset handler to default action after completion. default_signal_action.sa_flags = SA_RESETHAND; - sigaction(SIGABRT, &default_signal_action, 0); - sigaction(SIGTERM, &default_signal_action, 0); - sigaction(SIGSEGV, &default_signal_action, 0); - sigaction(SIGINT, &default_signal_action, 0); - sigaction(SIGXCPU, &default_signal_action, 0); + sigaction(SIGABRT, &default_signal_action, nullptr); + sigaction(SIGTERM, &default_signal_action, nullptr); + sigaction(SIGSEGV, &default_signal_action, nullptr); + sigaction(SIGINT, &default_signal_action, nullptr); + sigaction(SIGXCPU, &default_signal_action, nullptr); } void report_exit_code_reentrant(ExitCode exitcode) {