changeset 30835:2989202f92f8 stable

only allow range<FLOAT> to be instantiated * Range.h, Range.cc: Limit range<T> to floating point values. * range-fwd.h: Update forward declaration of range<T>. * ov-base.h, ov-base.cc, ov-range.h, ov-range.cc, ov.h, ov.cc, pt-eval.cc: Temporarily comment out code that uses range<INT> objects.
author John W. Eaton <jwe@octave.org>
date Thu, 17 Mar 2022 02:44:19 -0400
parents f1a9e55d850c
children 97504d2edcc7 4d2da8a3dca6
files libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-base.h libinterp/octave-value/ov-range.cc libinterp/octave-value/ov-range.h libinterp/octave-value/ov.cc libinterp/octave-value/ov.h libinterp/parse-tree/pt-eval.cc liboctave/array/Range.cc liboctave/array/Range.h liboctave/array/range-fwd.h
diffstat 10 files changed, 269 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-base.cc	Sun Mar 13 12:57:22 2022 -0400
+++ b/libinterp/octave-value/ov-base.cc	Thu Mar 17 02:44:19 2022 -0400
@@ -811,18 +811,22 @@
   err_wrong_type_arg ("octave_base_value::cellstr_value()", type_name ());
 }
 
+octave::range<double>
+octave_base_value::range_value (void) const
+{
+  err_wrong_type_arg ("octave_base_value::range_value()", type_name ());
+}
+
+// For now, disable all but range<double>.
+
+#if 0
+
 octave::range<float>
 octave_base_value::float_range_value (void) const
 {
   err_wrong_type_arg ("octave_base_value::float_range_value()", type_name ());
 }
 
-octave::range<double>
-octave_base_value::range_value (void) const
-{
-  err_wrong_type_arg ("octave_base_value::range_value()", type_name ());
-}
-
 octave::range<octave_int8>
 octave_base_value::int8_range_value (void) const
 {
@@ -871,6 +875,8 @@
   err_wrong_type_arg ("octave_base_value::uint64_range_value()", type_name ());
 }
 
+#endif
+
 octave_map
 octave_base_value::map_value (void) const
 {
--- a/libinterp/octave-value/ov-base.h	Sun Mar 13 12:57:22 2022 -0400
+++ b/libinterp/octave-value/ov-base.h	Thu Mar 17 02:44:19 2022 -0400
@@ -629,9 +629,13 @@
 
   virtual Array<std::string> cellstr_value (void) const;
 
-  virtual octave::range<float> float_range_value (void) const;
+  virtual octave::range<double> range_value (void) const;
+
+  // For now, disable all but range<double>.
 
-  virtual octave::range<double> range_value (void) const;
+#if 0
+
+  virtual octave::range<float> float_range_value (void) const;
 
   virtual octave::range<octave_int8> int8_range_value (void) const;
 
@@ -649,6 +653,8 @@
 
   virtual octave::range<octave_uint64> uint64_range_value (void) const;
 
+#endif
+
   virtual octave_map map_value (void) const;
 
   virtual octave_scalar_map scalar_map_value (void) const;
--- a/libinterp/octave-value/ov-range.cc	Sun Mar 13 12:57:22 2022 -0400
+++ b/libinterp/octave-value/ov-range.cc	Thu Mar 17 02:44:19 2022 -0400
@@ -67,10 +67,14 @@
 #if defined (HAVE_HDF5)
 
 template <>
-octave_hdf5_id ov_range<float>::hdf5_save_type = H5T_NATIVE_FLOAT;
+octave_hdf5_id ov_range<double>::hdf5_save_type = H5T_NATIVE_DOUBLE;
+
+// For now, disable all but ov_range<double>.
+
+#  if 0
 
 template <>
-octave_hdf5_id ov_range<double>::hdf5_save_type = H5T_NATIVE_DOUBLE;
+octave_hdf5_id ov_range<float>::hdf5_save_type = H5T_NATIVE_FLOAT;
 
 template <>
 octave_hdf5_id ov_range<octave_int8>::hdf5_save_type = H5T_NATIVE_INT8;
@@ -96,15 +100,21 @@
 template <>
 octave_hdf5_id ov_range<octave_uint64>::hdf5_save_type = H5T_NATIVE_UINT64;
 
+#  endif
+
 #else
 
 template <>
+octave_hdf5_id ov_range<double>::hdf5_save_type = 0;
+
+// For now, disable all but ov_range<double>.
+
+#if 0
+
+template <>
 octave_hdf5_id ov_range<float>::hdf5_save_type = 0;
 
 template <>
-octave_hdf5_id ov_range<double>::hdf5_save_type = 0;
-
-template <>
 octave_hdf5_id ov_range<octave_int8>::hdf5_save_type = 0;
 
 template <>
@@ -128,14 +138,20 @@
 template <>
 octave_hdf5_id ov_range<octave_uint64>::hdf5_save_type = 0;
 
+#  endif
+
 #endif
 
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<double>,
+                                              "range", "double");
+
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<float>,
                                               "float_range", "single");
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<double>,
-                                              "range", "double");
-
 DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_int8>,
                                               "int8_range", "int8");
 
@@ -160,6 +176,8 @@
 DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_uint64>,
                                               "uint64_range", "uint64");
 
+#endif
+
 template <typename T>
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
@@ -395,6 +413,17 @@
 }
 
 template <typename T>
+octave::range<double>
+ov_range<T>::range_value (void) const
+{
+  err_wrong_type_arg ("ov_range<T>::range_value()", type_name ());
+}
+
+// For now, disable all but ov_range<double>.
+
+#if 0
+
+template <typename T>
 octave::range<float>
 ov_range<T>::float_range_value (void) const
 {
@@ -402,13 +431,6 @@
 }
 
 template <typename T>
-octave::range<double>
-ov_range<T>::range_value (void) const
-{
-  err_wrong_type_arg ("ov_range<T>::range_value()", type_name ());
-}
-
-template <typename T>
 octave::range<octave_int8>
 ov_range<T>::int8_range_value (void) const
 {
@@ -464,6 +486,8 @@
   err_wrong_type_arg ("ov_range<T>::uint64_range_value ()", type_name ());
 }
 
+#endif
+
 template <typename T>
 octave_value
 ov_range<T>::convert_to_str_internal (bool pad, bool force, char type) const
@@ -691,6 +715,10 @@
 
 // specialize for saving with "reverse" flag
 
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 template <>
 bool
 ov_range<octave_uint8>::save_ascii (std::ostream& os)
@@ -719,6 +747,8 @@
   return xsave_ascii (os, m_range, true);
 }
 
+#endif
+
 template <typename T>
 bool
 xload_ascii (std::istream& is, octave::range<T>& r, const bool with_reverse)
@@ -756,6 +786,10 @@
 
 // specialize for loading with "reverse" flag
 
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 template <>
 bool
 ov_range<octave_uint8>::load_ascii (std::istream& is)
@@ -784,6 +818,8 @@
   return xload_ascii (is, m_range, true);
 }
 
+#endif
+
 /*
 %!test
 %! a = b = 1:4;
@@ -844,6 +880,10 @@
   return xsave_binary (os, save_as_floats, m_range, false);
 }
 
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 template <>
 bool
 ov_range<octave_uint8>::save_binary (std::ostream& os, bool save_as_floats)
@@ -872,6 +912,8 @@
   return xsave_binary (os, save_as_floats, m_range, true);
 }
 
+#endif
+
 template <typename T>
 bool
 xload_binary (std::istream& is, bool swap,
@@ -923,6 +965,10 @@
   return xload_binary (is, swap, fmt, m_range, false);
 }
 
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 template <>
 bool
 ov_range<octave_uint8>::load_binary (std::istream& is, bool swap,
@@ -955,6 +1001,8 @@
   return xload_binary (is, swap, fmt, m_range, true);
 }
 
+#endif
+
 /*
 %!test
 %! a = b = 1:4;
@@ -1101,6 +1149,10 @@
 #endif
 }
 
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 template <>
 bool
 ov_range<octave_uint8>::save_hdf5 (octave_hdf5_id loc_id, const char *name,
@@ -1177,6 +1229,8 @@
 #endif
 }
 
+#endif
+
 #if defined (HAVE_HDF5)
 
 template <typename T>
@@ -1260,6 +1314,10 @@
 #endif
 }
 
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 template <>
 bool
 ov_range<octave_uint8>::load_hdf5 (octave_hdf5_id loc_id, const char *name)
@@ -1324,6 +1382,8 @@
 #endif
 }
 
+#endif
+
 /*
 %!testif HAVE_HDF5
 %! a = b = 1:4;
@@ -1383,15 +1443,19 @@
 // Specializations.
 
 template <>
-octave::range<float>
-ov_range<float>::float_range_value (void) const
+octave::range<double>
+ov_range<double>::range_value (void) const
 {
   return m_range;
 }
 
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 template <>
-octave::range<double>
-ov_range<double>::range_value (void) const
+octave::range<float>
+ov_range<float>::float_range_value (void) const
 {
   return m_range;
 }
@@ -1452,6 +1516,8 @@
   return m_range;
 }
 
+#endif
+
 template <>
 octave::idx_vector
 ov_range<double>::index_vector (bool require_integers) const
--- a/libinterp/octave-value/ov-range.h	Sun Mar 13 12:57:22 2022 -0400
+++ b/libinterp/octave-value/ov-range.h	Thu Mar 17 02:44:19 2022 -0400
@@ -32,6 +32,7 @@
 
 #include <iosfwd>
 #include <string>
+#include <type_traits>
 
 #include "Array-fwd.h"
 #include "Range.h"
@@ -50,7 +51,8 @@
 
 class octave_value_list;
 
-// Range values.
+// For now, we only need ov_range<double> but we don't attempt to
+// enforce that restriction.
 
 template <typename T>
 class
@@ -384,9 +386,13 @@
     return raw_array_value ();
   }
 
-  OCTINTERP_API octave::range<float> float_range_value (void) const;
+  OCTINTERP_API octave::range<double> range_value (void) const;
+
+// For now, disable all but ov_range<double>.
 
-  OCTINTERP_API octave::range<double> range_value (void) const;
+#if 0
+
+  OCTINTERP_API octave::range<float> float_range_value (void) const;
 
   OCTINTERP_API octave::range<octave_int8> int8_range_value (void) const;
 
@@ -404,6 +410,8 @@
 
   OCTINTERP_API octave::range<octave_uint64> uint64_range_value (void) const;
 
+#endif
+
   OCTINTERP_API octave_value
   convert_to_str_internal (bool pad, bool force, char type) const;
 
@@ -494,8 +502,13 @@
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
 };
 
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, double)
+
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, float)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, double)
 DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_int8)
 DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_int16)
 DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_int32)
@@ -505,17 +518,23 @@
 DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_uint32)
 DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_uint64)
 
+#endif
+
 // Specializations.
 
 template <>
+OCTINTERP_API octave::range<double>
+ov_range<double>::range_value (void) const;
+
+// For now, disable all but ov_range<double>.
+
+#if 0
+
+template <>
 OCTINTERP_API octave::range<float>
 ov_range<float>::float_range_value (void) const;
 
 template <>
-OCTINTERP_API octave::range<double>
-ov_range<double>::range_value (void) const;
-
-template <>
 OCTINTERP_API octave::range<octave_int8>
 ov_range<octave_int8>::int8_range_value (void) const;
 
@@ -547,6 +566,8 @@
 OCTINTERP_API octave::range<octave_uint64>
 ov_range<octave_uint64>::uint64_range_value (void) const;
 
+#endif
+
 // The following specializations are here to preserve previous Range
 // performance until solutions can be generalized for other types.
 
@@ -576,8 +597,13 @@
 ov_range<double>::print_raw (std::ostream& os, bool pr_as_read_syntax) const;
 
 
+typedef ov_range<double> octave_double_range;
+
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 typedef ov_range<float> octave_float_range;
-typedef ov_range<double> octave_double_range;
 
 typedef ov_range<octave_int8> octave_int8_range;
 typedef ov_range<octave_int16> octave_int16_range;
@@ -589,6 +615,8 @@
 typedef ov_range<octave_uint32> octave_uint32_range;
 typedef ov_range<octave_uint64> octave_uint64_range;
 
+#endif
+
 typedef octave_double_range octave_range;
 
 #endif
--- a/libinterp/octave-value/ov.cc	Sun Mar 13 12:57:22 2022 -0400
+++ b/libinterp/octave-value/ov.cc	Thu Mar 17 02:44:19 2022 -0400
@@ -1093,23 +1093,18 @@
     return dynamic_cast<octave_base_value *> (new octave_matrix (r.matrix_value ()));
 }
 
-octave_value::octave_value (const octave::range<char>& r, char type,
-                            bool /*force_range*/)
-#if 0
-  : m_rep (force_range || optimize_range
-           ? dynamic_cast<octave_base_value *> (new octave_char_range (r, type))
-           : dynamic_cast<octave_base_value *> (type == '"'
-                                                ? new octave_char_matrix_dq_str (r.array_value ())
-                                                : new octave_char_matrix_sq_str (r.array_value ())))
-#else
-  : m_rep (type == '"'
-           ? new octave_char_matrix_dq_str (r.array_value ())
-           : new octave_char_matrix_sq_str (r.array_value ()))
-#endif
+octave_value::octave_value (const octave::range<double>& r, bool force_range)
+  : m_rep (force_range || Voptimize_range
+           ? dynamic_cast<octave_base_value *> (new ov_range<double> (r))
+           : dynamic_cast<octave_base_value *> (new octave_matrix (r.array_value ())))
 {
   maybe_mutate ();
 }
 
+// For now, disable all but range<double>.
+
+#if 0
+
 octave_value::octave_value (const octave::range<float>& r, bool force_range)
   : m_rep (force_range || Voptimize_range
            ? dynamic_cast<octave_base_value *> (new ov_range<float> (r))
@@ -1118,14 +1113,6 @@
   maybe_mutate ();
 }
 
-octave_value::octave_value (const octave::range<double>& r, bool force_range)
-  : m_rep (force_range || Voptimize_range
-           ? dynamic_cast<octave_base_value *> (new ov_range<double> (r))
-           : dynamic_cast<octave_base_value *> (new octave_matrix (r.array_value ())))
-{
-  maybe_mutate ();
-}
-
 octave_value::octave_value (const octave::range<octave_int8>& r,
                             bool force_range)
   : m_rep (force_range || Voptimize_range
@@ -1198,6 +1185,25 @@
   maybe_mutate ();
 }
 
+octave_value::octave_value (const octave::range<char>& r, char type,
+                            bool /*force_range*/)
+#if 0
+  : m_rep (force_range || optimize_range
+           ? dynamic_cast<octave_base_value *> (new octave_char_range (r, type))
+           : dynamic_cast<octave_base_value *> (type == '"'
+                                                ? new octave_char_matrix_dq_str (r.array_value ())
+                                                : new octave_char_matrix_sq_str (r.array_value ())))
+#else
+  : m_rep (type == '"'
+           ? new octave_char_matrix_dq_str (r.array_value ())
+           : new octave_char_matrix_sq_str (r.array_value ()))
+#endif
+{
+  maybe_mutate ();
+}
+
+#endif
+
 octave_value::octave_value (const octave_map& m)
   : m_rep (new octave_struct (m))
 {
@@ -2229,8 +2235,13 @@
 XVALUE_EXTRACTOR (Cell, xcell_value, cell_value)
 XVALUE_EXTRACTOR (Array<std::string>, xcellstr_value, cellstr_value)
 
+XVALUE_EXTRACTOR (octave::range<double>, xrange_value, range_value)
+
+// For now, disable all but ov_range<double>.
+
+#if 0
+
 XVALUE_EXTRACTOR (octave::range<float>, xfloat_range_value, float_range_value)
-XVALUE_EXTRACTOR (octave::range<double>, xrange_value, range_value)
 XVALUE_EXTRACTOR (octave::range<octave_int8>, xint8_range_value, int8_range_value)
 XVALUE_EXTRACTOR (octave::range<octave_int16>, xint16_range_value, int16_range_value)
 XVALUE_EXTRACTOR (octave::range<octave_int32>, xint32_range_value, int32_range_value)
@@ -2240,6 +2251,8 @@
 XVALUE_EXTRACTOR (octave::range<octave_uint32>, xuint32_range_value, uint32_range_value)
 XVALUE_EXTRACTOR (octave::range<octave_uint64>, xuint64_range_value, uint64_range_value)
 
+#endif
+
 XVALUE_EXTRACTOR (octave_map, xmap_value, map_value)
 XVALUE_EXTRACTOR (octave_scalar_map, xscalar_map_value, scalar_map_value)
 
@@ -3523,8 +3536,13 @@
   octave_diag_matrix::register_type (ti);
   octave_complex_matrix::register_type (ti);
   octave_complex_diag_matrix::register_type (ti);
+  ov_range<double>::register_type (ti);
+
+  // For now, disable all but ov_range<double>.
+
+#if 0
+
   ov_range<float>::register_type (ti);
-  ov_range<double>::register_type (ti);
   ov_range<octave_int8>::register_type (ti);
   ov_range<octave_int16>::register_type (ti);
   ov_range<octave_int32>::register_type (ti);
@@ -3533,6 +3551,9 @@
   ov_range<octave_uint16>::register_type (ti);
   ov_range<octave_uint32>::register_type (ti);
   ov_range<octave_uint64>::register_type (ti);
+
+#endif
+
   octave_bool::register_type (ti);
   octave_bool_matrix::register_type (ti);
   octave_char_matrix_str::register_type (ti);
--- a/libinterp/octave-value/ov.h	Sun Mar 13 12:57:22 2022 -0400
+++ b/libinterp/octave-value/ov.h	Thu Mar 17 02:44:19 2022 -0400
@@ -316,28 +316,44 @@
   }
 #endif
 
-  OCTINTERP_API octave_value (const octave::range<char>& r, char type,
+  OCTINTERP_API octave_value (const octave::range<double>& r,
                               bool force_range = false);
+
+  // For now, disable all but range<double>.
+
+#if 0
+
   OCTINTERP_API octave_value (const octave::range<float>& r,
                               bool force_range = false);
-  OCTINTERP_API octave_value (const octave::range<double>& r,
-                              bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_int8>& r,
                               bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_int16>& r,
                               bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_int32>& r,
                               bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_int64>& r,
                               bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_uint8>& r,
                               bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_uint16>& r,
                               bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_uint32>& r,
                               bool force_range = false);
+
   OCTINTERP_API octave_value (const octave::range<octave_uint64>& r,
                               bool force_range = false);
+
+  OCTINTERP_API octave_value (const octave::range<char>& r, char type,
+                              bool force_range = false);
+#endif
+
   OCTINTERP_API octave_value (const octave_map& m);
   OCTINTERP_API octave_value (const octave_scalar_map& m);
   OCTINTERP_API octave_value (const std::map<std::string, octave_value>&);
@@ -1008,12 +1024,16 @@
   Array<std::string> cellstr_value (void) const
   { return m_rep->cellstr_value (); }
 
+  octave::range<double> range_value (void) const
+  { return m_rep->range_value (); }
+
+  // For now, disable all but range<double>.
+
+#if 0
+
   octave::range<float> float_range_value (void) const
   { return m_rep->float_range_value (); }
 
-  octave::range<double> range_value (void) const
-  { return m_rep->range_value (); }
-
   octave::range<octave_int8> int8_range_value (void) const
   { return m_rep->int8_range_value (); }
 
@@ -1038,6 +1058,8 @@
   octave::range<octave_uint64> uint64_range_value (void) const
   { return m_rep->uint64_range_value (); }
 
+#endif
+
   OCTINTERP_API octave_map map_value (void) const;
 
   OCTINTERP_API octave_scalar_map scalar_map_value (void) const;
@@ -1269,12 +1291,16 @@
 
   OCTINTERP_API Array<std::string> xcellstr_value (const char *fmt, ...) const;
 
+  OCTINTERP_API octave::range<double>
+  xrange_value (const char *fmt, ...) const;
+
+  // For now, disable all but range<double>.
+
+#if 0
+
   OCTINTERP_API octave::range<float>
   xfloat_range_value (const char *fmt, ...) const;
 
-  OCTINTERP_API octave::range<double>
-  xrange_value (const char *fmt, ...) const;
-
   OCTINTERP_API octave::range<octave_int8>
   xint8_range_value (const char *fmt, ...) const;
 
@@ -1299,6 +1325,8 @@
   OCTINTERP_API octave::range<octave_uint64>
   xuint64_range_value (const char *fmt, ...) const;
 
+#endif
+
   OCTINTERP_API octave_map xmap_value (const char *fmt, ...) const;
 
   OCTINTERP_API octave_scalar_map
--- a/libinterp/parse-tree/pt-eval.cc	Sun Mar 13 12:57:22 2022 -0400
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Mar 17 02:44:19 2022 -0400
@@ -3096,6 +3096,9 @@
             return;
           }
 
+        // For now, disable all but range<double>.
+
+#if 0
         if (rhs.is_int64_type ())
           {
             execute_range_loop (rhs.int64_range_value (), line, ult, loop_body);
@@ -3149,6 +3152,7 @@
             execute_range_loop (rhs.float_range_value (), line, ult, loop_body);
             return;
           }
+#endif
       }
 
     if (rhs.is_scalar_type ())
--- a/liboctave/array/Range.cc	Sun Mar 13 12:57:22 2022 -0400
+++ b/liboctave/array/Range.cc	Thu Mar 17 02:44:19 2022 -0400
@@ -328,6 +328,10 @@
     xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
   }
 
+  // For now, only define for float and double.
+
+#if 0
+
   template <>
   void
   range<octave_int8>::init (void)
@@ -384,6 +388,8 @@
     xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
   }
 
+#endif
+
   template <>
   bool
   range<double>::is_storable (void) const
--- a/liboctave/array/Range.h	Sun Mar 13 12:57:22 2022 -0400
+++ b/liboctave/array/Range.h	Thu Mar 17 02:44:19 2022 -0400
@@ -29,6 +29,7 @@
 #include "octave-config.h"
 
 #include <iosfwd>
+#include <type_traits>
 
 #include "Array-fwd.h"
 #include "dMatrix.h"
@@ -39,8 +40,13 @@
 
 namespace octave
 {
+  // For now, only define for floating point types.  However, we only
+  // need range<float> as a temporary local variable in make_float_range
+  // in ov.cc.
+
   template <typename T>
-  class range
+  class
+  range<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
   {
   public:
 
@@ -123,9 +129,26 @@
       return range<T> (base, increment, final_val, numel, reverse);
     }
 
-    range (const range<T>&) = default;
+    range (const range<T>& r)
+      : m_base (r.m_base), m_increment (r.m_increment),
+        m_limit (r.m_limit), m_final (r.m_final),
+        m_numel (r.m_numel), m_reverse (r.m_reverse)
+    { }
 
-    range<T>& operator = (const range<T>&) = default;
+    range<T>& operator = (const range<T>& r)
+    {
+      if (this != &r)
+        {
+          m_base = r.m_base;
+          m_increment = r.m_increment;
+          m_limit = r.m_limit;
+          m_final = r.m_final;
+          m_numel = r.m_numel;
+          m_reverse = r.m_reverse;
+        }
+
+      return *this;
+    }
 
     ~range (void) = default;
 
@@ -370,6 +393,13 @@
 
   template <> OCTAVE_API void range<double>::init (void);
   template <> OCTAVE_API void range<float>::init (void);
+
+  // For now, only define for floating point types.  However, we only
+  // need range<float> as a temporary local variable in make_float_range
+  // in ov.cc.
+
+#if 0
+
   template <> OCTAVE_API void range<octave_int8>::init (void);
   template <> OCTAVE_API void range<octave_int16>::init (void);
   template <> OCTAVE_API void range<octave_int32>::init (void);
@@ -379,6 +409,8 @@
   template <> OCTAVE_API void range<octave_uint32>::init (void);
   template <> OCTAVE_API void range<octave_uint64>::init (void);
 
+#endif
+
   template <> OCTAVE_API bool range<double>::is_storable (void) const;
   template <> OCTAVE_API bool range<float>::is_storable (void) const;
 
--- a/liboctave/array/range-fwd.h	Sun Mar 13 12:57:22 2022 -0400
+++ b/liboctave/array/range-fwd.h	Thu Mar 17 02:44:19 2022 -0400
@@ -30,7 +30,7 @@
 
 namespace octave
 {
-  template <typename T> class OCTAVE_API range;
+  template <typename T, typename ENABLE = void> class OCTAVE_API range;
 }
 
 #endif