diff libinterp/corefcn/pr-output.cc @ 24747:6114be517240

* pr-output.cc: Move defn of specialized abs before first use (bug #53114)
author John W. Eaton <jwe@octave.org>
date Tue, 13 Feb 2018 13:09:45 -0500
parents d2467914ce33
children b784d68f7c44
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc	Tue Feb 13 11:02:21 2018 -0500
+++ b/libinterp/corefcn/pr-output.cc	Tue Feb 13 13:09:45 2018 -0500
@@ -1647,6 +1647,42 @@
   return make_format (FloatComplexMatrix (nda), r_fw, i_fw, scale);
 }
 
+// FIXME: all this mess with abs is an attempt to avoid seeing
+//
+//   warning: comparison of unsigned expression < 0 is always false
+//
+// from GCC.  Isn't there a better way?
+
+template <typename T>
+/* static */ inline T
+abs (T x)
+{
+  return x < 0 ? -x : x;
+}
+
+#define INSTANTIATE_ABS(T)                      \
+  template /* static */ T abs (T)
+
+INSTANTIATE_ABS(signed char);
+INSTANTIATE_ABS(short);
+INSTANTIATE_ABS(int);
+INSTANTIATE_ABS(long);
+INSTANTIATE_ABS(long long);
+
+#define SPECIALIZE_UABS(T)                      \
+  template <>                                   \
+  /* static */ inline unsigned T                \
+  abs (unsigned T x)                            \
+  {                                             \
+    return x;                                   \
+  }
+
+SPECIALIZE_UABS(char)
+SPECIALIZE_UABS(short)
+SPECIALIZE_UABS(int)
+SPECIALIZE_UABS(long)
+SPECIALIZE_UABS(long long)
+
 #define MAKE_INT_MATRIX_FORMAT(TYPE)                                    \
   template <>                                                           \
   float_display_format                                                  \
@@ -3090,42 +3126,6 @@
     }
 }
 
-// FIXME: all this mess with abs is an attempt to avoid seeing
-//
-//   warning: comparison of unsigned expression < 0 is always false
-//
-// from GCC.  Isn't there a better way?
-
-template <typename T>
-/* static */ inline T
-abs (T x)
-{
-  return x < 0 ? -x : x;
-}
-
-#define INSTANTIATE_ABS(T)                      \
-  template /* static */ T abs (T)
-
-INSTANTIATE_ABS(signed char);
-INSTANTIATE_ABS(short);
-INSTANTIATE_ABS(int);
-INSTANTIATE_ABS(long);
-INSTANTIATE_ABS(long long);
-
-#define SPECIALIZE_UABS(T)                      \
-  template <>                                   \
-  /* static */ inline unsigned T                \
-  abs (unsigned T x)                            \
-  {                                             \
-    return x;                                   \
-  }
-
-SPECIALIZE_UABS(char)
-SPECIALIZE_UABS(short)
-SPECIALIZE_UABS(int)
-SPECIALIZE_UABS(long)
-SPECIALIZE_UABS(long long)
-
 template void
 pr_int (std::ostream&, const octave_int8&, int);