diff liboctave/dim-vector.cc @ 10830:b4ebfd675321

avoid static initialization disaster in dim_vector
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 29 Jul 2010 08:47:26 +0200
parents 6683f0c9d742
children fd0a3ac60b0e
line wrap: on
line diff
--- a/liboctave/dim-vector.cc
+++ b/liboctave/dim-vector.cc
@@ -33,8 +33,11 @@
 // off the maximum value of octave_idx_type.
 // Currently 1 is subtracted to allow safe conversion of any 2D Array into Sparse,
 // but this offset may change in the future.
-const octave_idx_type
-dim_vector::dim_max = std::numeric_limits<octave_idx_type>::max () - 1;
+octave_idx_type
+dim_vector::dim_max (void)
+{
+  return std::numeric_limits<octave_idx_type>::max () - 1;
+}
 
 void
 dim_vector::chop_all_singletons (void)
@@ -89,7 +92,7 @@
 octave_idx_type
 dim_vector::safe_numel (void) const
 {
-  octave_idx_type idx_max = dim_max;
+  octave_idx_type idx_max = dim_max ();
   octave_idx_type n = 1;
   int n_dims = length ();