diff -r 758de955caca libinterp/octave-value/ov-classdef.cc
--- a/libinterp/octave-value/ov-classdef.cc	Tue Feb 07 08:18:54 2023 -0800
+++ b/libinterp/octave-value/ov-classdef.cc	Tue Feb 07 17:42:15 2023 -0500
@@ -157,7 +157,7 @@ octave_classdef::subsref (const std::str
 
           retval = meth.execute (args, 1, true, "subsref");
 
-          return retval.length () > 0 ? retval(0) : octave_value ();
+          return retval.first_or_nil_ov ();
         }
     }
 
@@ -167,7 +167,7 @@ octave_classdef::subsref (const std::str
   if (type.length () > skip && idx.size () > skip)
     retval = retval(0).next_subsref (1, type, idx, skip);
 
-  return retval.length () > 0 ? retval(0) : octave_value ();
+  return retval.first_or_nil_ov ();
 }
 
 octave_value
diff -r 758de955caca libinterp/octave-value/ovl.h
--- a/libinterp/octave-value/ovl.h	Tue Feb 07 08:18:54 2023 -0800
+++ b/libinterp/octave-value/ovl.h	Tue Feb 07 17:42:15 2023 -0500
@@ -172,6 +172,14 @@ public:
 
   void clear () { m_data.clear (); }
 
+  octave_value first_or_nil_ov () const
+  {
+    if (length ())
+      return m_data.front ();
+
+    return octave_value ();
+  }
+
 private:
 
   std::vector<octave_value> m_data;
diff -r 758de955caca libinterp/parse-tree/pt-assign.h
--- a/libinterp/parse-tree/pt-assign.h	Tue Feb 07 08:18:54 2023 -0800
+++ b/libinterp/parse-tree/pt-assign.h	Tue Feb 07 17:42:15 2023 -0500
@@ -155,7 +155,7 @@ public:
   {
     octave_value_list retval = evaluate_n (tw, nargout);
 
-    return retval.length () > 0 ? retval(0) : octave_value ();
+    return retval.first_or_nil_ov ();
   }
 
   octave_value_list evaluate_n (tree_evaluator& tw, int nargout = 1);
diff -r 758de955caca libinterp/parse-tree/pt-classdef.h
--- a/libinterp/parse-tree/pt-classdef.h	Tue Feb 07 08:18:54 2023 -0800
+++ b/libinterp/parse-tree/pt-classdef.h	Tue Feb 07 17:42:15 2023 -0500
@@ -76,7 +76,7 @@ public:
   {
     octave_value_list retval = evaluate_n (tw, nargout);
 
-    return retval.length () > 0 ? retval(0) : octave_value ();
+    return retval.first_or_nil_ov ();
   }
 
   octave_value_list evaluate_n (tree_evaluator& tw, int nargout = 1);
diff -r 758de955caca libinterp/parse-tree/pt-id.cc
--- a/libinterp/parse-tree/pt-id.cc	Tue Feb 07 08:18:54 2023 -0800
+++ b/libinterp/parse-tree/pt-id.cc	Tue Feb 07 17:42:15 2023 -0500
@@ -92,8 +92,6 @@ tree_identifier::dup (symbol_scope& scop
 octave_value_list
 tree_identifier::evaluate_n (tree_evaluator& tw, int nargout)
 {
-  octave_value_list retval;
-
   octave_value val = tw.varval (m_sym);
 
   if (val.is_undefined ())
@@ -126,7 +124,7 @@ tree_identifier::evaluate_n (tree_evalua
       if (fcn && ! (is_postfix_indexed ()
                     && fcn->accepts_postfix_index (postfix_index ())))
         {
-          retval = fcn->call (tw, nargout);
+          return fcn->call (tw, nargout);
         }
       else
         {
@@ -141,7 +139,7 @@ tree_identifier::evaluate_n (tree_evalua
               interp.feval ("display", args);
             }
 
-          retval = ovl (val);
+          return ovl (val);
         }
     }
   else if (m_sym.is_added_static ())
@@ -149,7 +147,8 @@ tree_identifier::evaluate_n (tree_evalua
   else
     eval_undefined_error ();
 
-  return retval;
+  // Unreachable
+  __builtin_unreachable ();
 }
 
 octave_lvalue
diff -r 758de955caca libinterp/parse-tree/pt-id.h
--- a/libinterp/parse-tree/pt-id.h	Tue Feb 07 08:18:54 2023 -0800
+++ b/libinterp/parse-tree/pt-id.h	Tue Feb 07 17:42:15 2023 -0500
@@ -83,7 +83,7 @@ public:
 
   octave_lvalue lvalue (tree_evaluator& tw);
 
-  void eval_undefined_error ();
+  void eval_undefined_error () OCTAVE_NORETURN;
 
   void static_workspace_error ()
   {
@@ -97,7 +97,7 @@ public:
   {
     octave_value_list retval = evaluate_n (tw, nargout);
 
-    return retval.length () > 0 ? retval(0) : octave_value ();
+    return retval.first_or_nil_ov () ;
   }
 
   octave_value_list evaluate_n (tree_evaluator& tw, int nargout = 1);
diff -r 758de955caca libinterp/parse-tree/pt-idx.h
--- a/libinterp/parse-tree/pt-idx.h	Tue Feb 07 08:18:54 2023 -0800
+++ b/libinterp/parse-tree/pt-idx.h	Tue Feb 07 17:42:15 2023 -0500
@@ -107,7 +107,7 @@ public:
   {
     octave_value_list retval = evaluate_n (tw, nargout);
 
-    return retval.length () > 0 ? retval(0) : octave_value ();
+    return retval.first_or_nil_ov ();
   }
 
   octave_value_list evaluate_n (tree_evaluator& tw, int nargout = 1);
