lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 5c76c96 2/6: Initialize local POD variables a


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 5c76c96 2/6: Initialize local POD variables at point of declaration [404]
Date: Tue, 31 Jan 2017 21:20:57 +0000 (UTC)

branch: master
commit 5c76c969219c40a2f9289001a48f0fa8374f5e2e
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Initialize local POD variables at point of declaration [404]
    
    These were previously uninitialized [C++11 8.5/11], so their values
    were indeterminate, and using them would have engendered UB. Now they
    are appropriately initialized to diagnosably invalid values--which are
    now actually diagnosed.
---
 input_sequence.cpp |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/input_sequence.cpp b/input_sequence.cpp
index dda2242..e7a7eda 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -532,8 +532,8 @@ void InputSequence::intervalic_duration()
         + begin_excl
         ;
     duration_mode tentative_begin_duration_mode = current_duration_scalar_mode;
-    int tentative_end_duration;
-    duration_mode tentative_end_duration_mode;// TODO ?? expunge = e_duration;;
+    int tentative_end_duration = -1;
+    duration_mode tentative_end_duration_mode = e_invalid_mode;
     match(e_minor_separator); // TODO ?? Require this?
     duration_scalar();
     if
@@ -617,6 +617,21 @@ void InputSequence::validate_duration
         mark_diagnostic_context();
         return;
         }
+    else if
+        (  e_invalid_mode == tentative_begin_duration_mode
+        || e_invalid_mode == tentative_end_duration_mode
+        )
+        {
+        current_interval.insane = true;
+        diagnostics
+            << "Interval "
+            << "[ " << tentative_begin_duration << ", "
+            << tentative_end_duration << " )"
+            << " has an invalid duration mode. "
+            ;
+        mark_diagnostic_context();
+        return;
+        }
     else
         {
         current_interval.begin_duration = tentative_begin_duration     ;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]