From 417e4e8f68aec79750ed9beda54b209969e6a2f2 Mon Sep 17 00:00:00 2001
From: thorstenhater <24411438+thorstenhater@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:26:32 +0200
Subject: [PATCH] Resolve uninitialised values. (#1616)

- Fixes a set of undefined value warnings.
- merge identical `case`s
---
 arbor/backends/event.hpp                      | 6 +++---
 arbor/fvm_lowered_cell.hpp                    | 2 +-
 arbor/fvm_lowered_cell_impl.hpp               | 2 +-
 arbor/include/arbor/common_types.hpp          | 6 +++---
 arbor/include/arbor/fvm_types.hpp             | 4 ++--
 arbor/include/arbor/profile/meter_manager.hpp | 2 +-
 arbor/include/arbor/simd/simd.hpp             | 4 ----
 7 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/arbor/backends/event.hpp b/arbor/backends/event.hpp
index 508c2b96..d6656102 100644
--- a/arbor/backends/event.hpp
+++ b/arbor/backends/event.hpp
@@ -21,11 +21,11 @@ struct target_handle {
 };
 
 struct deliverable_event {
-    time_type time;
-    float weight;
+    time_type time = 0;
+    float weight = 0;
     target_handle handle;
 
-    deliverable_event() {}
+    deliverable_event() = default;
     deliverable_event(time_type time, target_handle handle, float weight):
         time(time), weight(weight), handle(handle) {}
 };
diff --git a/arbor/fvm_lowered_cell.hpp b/arbor/fvm_lowered_cell.hpp
index 38550be2..6aec640a 100644
--- a/arbor/fvm_lowered_cell.hpp
+++ b/arbor/fvm_lowered_cell.hpp
@@ -50,7 +50,7 @@ struct fvm_probe_scalar {
 
 struct fvm_probe_interpolated {
     probe_handle raw_handles[2] = {nullptr, nullptr};
-    double coef[2];
+    double coef[2] = {};
     mlocation metadata;
 
     util::any_ptr get_metadata_ptr() const { return &metadata; }
diff --git a/arbor/fvm_lowered_cell_impl.hpp b/arbor/fvm_lowered_cell_impl.hpp
index 90206ad4..9e4f5ed8 100644
--- a/arbor/fvm_lowered_cell_impl.hpp
+++ b/arbor/fvm_lowered_cell_impl.hpp
@@ -108,7 +108,7 @@ private:
     value_type check_voltage_mV_ = 0;
 
     // Flag indicating that at least one of the mechanisms implements the post_events procedure
-    bool post_events_;
+    bool post_events_ = false;
 
     // Host-side views/copies and local state.
     decltype(backend::host_view(sample_time_)) sample_time_host_;
diff --git a/arbor/include/arbor/common_types.hpp b/arbor/include/arbor/common_types.hpp
index e9bacd12..75141c06 100644
--- a/arbor/include/arbor/common_types.hpp
+++ b/arbor/include/arbor/common_types.hpp
@@ -58,9 +58,9 @@ struct cell_member_type {
 // Pair of indexes that describe range of local indices.
 
 struct lid_range {
-    cell_lid_type begin;
-    cell_lid_type end;
-    lid_range() {};
+    cell_lid_type begin = 0;
+    cell_lid_type end = 0;
+    lid_range() = default;
     lid_range(cell_lid_type b, cell_lid_type e):
         begin(b), end(e) {}
 };
diff --git a/arbor/include/arbor/fvm_types.hpp b/arbor/include/arbor/fvm_types.hpp
index ea3f21f3..0331b294 100644
--- a/arbor/include/arbor/fvm_types.hpp
+++ b/arbor/include/arbor/fvm_types.hpp
@@ -14,9 +14,9 @@ struct fvm_gap_junction {
     using index_type = fvm_index_type;
 
     std::pair<index_type, index_type> loc;
-    value_type weight;
+    value_type weight = 0;
 
-    fvm_gap_junction() {}
+    fvm_gap_junction() = default;
     fvm_gap_junction(std::pair<index_type, index_type> l, value_type w): loc(l), weight(w) {}
 };
 
diff --git a/arbor/include/arbor/profile/meter_manager.hpp b/arbor/include/arbor/profile/meter_manager.hpp
index a2da58b0..9459023f 100644
--- a/arbor/include/arbor/profile/meter_manager.hpp
+++ b/arbor/include/arbor/profile/meter_manager.hpp
@@ -32,7 +32,7 @@ class meter_manager {
 private:
     bool started_ = false;
 
-    tick_type start_time_;
+    tick_type start_time_ = 0;
     std::vector<double> times_;
 
     std::vector<std::unique_ptr<meter>> meters_;
diff --git a/arbor/include/arbor/simd/simd.hpp b/arbor/include/arbor/simd/simd.hpp
index 9345e8ec..0c5f05cd 100644
--- a/arbor/include/arbor/simd/simd.hpp
+++ b/arbor/include/arbor/simd/simd.hpp
@@ -481,8 +481,6 @@ namespace detail {
             using IndexImpl = typename Index::simd_base;
             switch (pi.constraint) {
             case index_constraint::none:
-                value_ = Impl::gather(tag<IndexImpl>{}, pi.p, pi.index.value_);
-                break;
             case index_constraint::independent:
                 value_ = Impl::gather(tag<IndexImpl>{}, pi.p, pi.index.value_);
                 break;
@@ -507,8 +505,6 @@ namespace detail {
             using IndexImpl = typename Index::simd_base;
             switch (pi.constraint) {
             case index_constraint::none:
-                value_ = Impl::gather(tag<IndexImpl>{}, pi.p, pi.index.value_);
-                break;
             case index_constraint::independent:
                 value_ = Impl::gather(tag<IndexImpl>{}, pi.p, pi.index.value_);
                 break;
-- 
GitLab