changeset 5760:8d7162924bd3

[project @ 2006-04-14 04:01:37 by jwe]
author jwe
date Fri, 14 Apr 2006 04:01:40 +0000
parents ce79d238f142
children f78d64fbe590
files ChangeLog configure.in libcruft/ChangeLog libcruft/misc/f77-fcn.h libcruft/misc/quit.h liboctave/CSparse.cc liboctave/ChangeLog liboctave/DiagArray2.h liboctave/Sparse.cc liboctave/SparseCmplxLU.cc liboctave/SparsedbleLU.cc liboctave/dSparse.cc liboctave/data-conv.cc liboctave/kpse.cc liboctave/oct-alloc.cc liboctave/oct-sort.cc liboctave/prog-args.cc liboctave/sparse-base-chol.cc liboctave/str-vec.cc src/ChangeLog src/DLD-FUNCTIONS/besselj.cc src/DLD-FUNCTIONS/ccolamd.cc src/DLD-FUNCTIONS/chol.cc src/DLD-FUNCTIONS/colamd.cc src/DLD-FUNCTIONS/dispatch.cc src/DLD-FUNCTIONS/matrix_type.cc src/DLD-FUNCTIONS/rand.cc src/DLD-FUNCTIONS/regexp.cc src/DLD-FUNCTIONS/sort.cc src/DLD-FUNCTIONS/sparse.cc src/DLD-FUNCTIONS/spchol.cc src/DLD-FUNCTIONS/splu.cc src/Makefile.in src/OPERATORS/op-cm-scm.cc src/OPERATORS/op-cm-sm.cc src/OPERATORS/op-cs-scm.cc src/OPERATORS/op-cs-sm.cc src/OPERATORS/op-m-scm.cc src/OPERATORS/op-m-sm.cc src/OPERATORS/op-s-scm.cc src/OPERATORS/op-s-sm.cc src/OPERATORS/op-scm-cm.cc src/OPERATORS/op-scm-cs.cc src/OPERATORS/op-scm-m.cc src/OPERATORS/op-scm-s.cc src/OPERATORS/op-scm-scm.cc src/OPERATORS/op-scm-sm.cc src/OPERATORS/op-sm-cm.cc src/OPERATORS/op-sm-cs.cc src/OPERATORS/op-sm-m.cc src/OPERATORS/op-sm-s.cc src/OPERATORS/op-sm-scm.cc src/OPERATORS/op-sm-sm.cc src/OPERATORS/op-streamoff.cc src/dynamic-ld.cc src/load-save.cc src/ls-hdf5.cc src/ls-mat4.cc src/ls-mat5.cc src/ls-oct-binary.cc src/mappers.cc src/oct-procbuf.cc src/oct-stream.cc src/ops.h src/ov-base-int.cc src/ov-base-sparse.h src/ov-bool-mat.cc src/ov-bool-sparse.cc src/ov-bool.cc src/ov-cell.cc src/ov-complex.cc src/ov-cx-mat.cc src/ov-cx-sparse.cc src/ov-fcn-handle.cc src/ov-fcn-inline.cc src/ov-list.cc src/ov-range.cc src/ov-re-mat.cc src/ov-re-sparse.cc src/ov-scalar.cc src/ov-str-mat.cc src/ov-struct.cc src/ov-typeinfo.h src/parse.y src/pt-arg-list.cc src/pt-pr-code.cc src/symtab.cc src/unwind-prot.cc src/unwind-prot.h src/variables.cc
diffstat 90 files changed, 784 insertions(+), 626 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Apr 13 13:04:33 2006 +0000
+++ b/ChangeLog	Fri Apr 14 04:01:40 2006 +0000
@@ -1,3 +1,8 @@
+2006-04-13  John W. Eaton  <jwe@octave.org>
+
+	* configure.in (CONST_CAST, DYNAMIC_CAST, REINTERPRET_CAST,
+	STATIC_CAST): Delete.
+
 2006-04-12  John W. Eaton  <jwe@octave.org>
 
 	* configure.in: If using g++, also add -Wold-style-cast to CXXFLAGS.
--- a/configure.in	Thu Apr 13 13:04:33 2006 +0000
+++ b/configure.in	Fri Apr 14 04:01:40 2006 +0000
@@ -29,7 +29,7 @@
 EXTERN_CXXFLAGS="$CXXFLAGS"
 
 AC_INIT
-AC_REVISION($Revision: 1.506 $)
+AC_REVISION($Revision: 1.507 $)
 AC_PREREQ(2.57)
 AC_CONFIG_SRCDIR([src/octave.cc])
 AC_CONFIG_HEADER(config.h)
@@ -1648,14 +1648,6 @@
 #define GCC_ATTR_UNUSED
 #endif
 
-#define CONST_CAST(T, E) (T) (E)
-
-#define DYNAMIC_CAST(T, E) (T) (E)
-
-#define REINTERPRET_CAST(T, E) (T) (E)
-
-#define STATIC_CAST(T, E) (T) (E)
-
 #define X_CAST(T, E) (T) (E)
 
 #if defined(HAVE_F2C) && !defined(F77_FUNC)
--- a/libcruft/ChangeLog	Thu Apr 13 13:04:33 2006 +0000
+++ b/libcruft/ChangeLog	Fri Apr 14 04:01:40 2006 +0000
@@ -1,3 +1,9 @@
+2006-04-13  John W. Eaton  <jwe@octave.org>
+
+	* misc/quit.h BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_1,
+	END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE): Omit unnecessary casts.
+	* misc/f77-fcn.h (F77_XFCN, F77_CHAR_ARG_LEN): Likewise.
+
 2006-04-03  David Bateman  <dbateman@free.fr>
 
 	* ranlib/wrap.f (dgenexp, dgengam, dignpoi): New functions.
--- a/libcruft/misc/f77-fcn.h	Thu Apr 13 13:04:33 2006 +0000
+++ b/libcruft/misc/f77-fcn.h	Fri Apr 14 04:01:40 2006 +0000
@@ -55,11 +55,11 @@
       octave_jmp_buf saved_context; \
       f77_exception_encountered = 0; \
       sig_atomic_t saved_octave_interrupt_immediately = octave_interrupt_immediately; \
-      octave_save_current_context ((char *) saved_context); \
+      octave_save_current_context (saved_context); \
       if (octave_set_current_context) \
 	{ \
 	  octave_interrupt_immediately = saved_octave_interrupt_immediately; \
-          octave_restore_current_context ((char *) saved_context); \
+          octave_restore_current_context (saved_context); \
 	  if (f77_exception_encountered) \
 	    F77_XFCN_ERROR (f, F); \
           else if (octave_allocation_error) \
@@ -72,7 +72,7 @@
 	  octave_interrupt_immediately++; \
 	  F77_FUNC (f, F) args; \
 	  octave_interrupt_immediately--; \
-          octave_restore_current_context ((char *) saved_context); \
+          octave_restore_current_context (saved_context); \
         } \
     } \
   while (0)
@@ -169,7 +169,7 @@
 #define F77_CHAR_ARG2(x, l) x
 #define F77_CONST_CHAR_ARG2(x, l) F77_CHAR_ARG2 (x, l)
 #define F77_CXX_STRING_ARG(x) F77_CONST_CHAR_ARG2 (x.c_str (), x.length ())
-#define F77_CHAR_ARG_LEN(l) , (long) l
+#define F77_CHAR_ARG_LEN(l) , l
 #define F77_CHAR_ARG_DECL char *
 #define F77_CONST_CHAR_ARG_DECL const char *
 #define F77_CHAR_ARG_LEN_DECL , long
--- a/libcruft/misc/quit.h	Thu Apr 13 13:04:33 2006 +0000
+++ b/libcruft/misc/quit.h	Fri Apr 14 04:01:40 2006 +0000
@@ -134,11 +134,11 @@
     { \
       octave_jmp_buf saved_context; \
  \
-      octave_save_current_context ((char *) saved_context); \
+      octave_save_current_context (saved_context); \
  \
       if (octave_set_current_context) \
 	{ \
-	  octave_restore_current_context ((char *) saved_context)
+	  octave_restore_current_context (saved_context)
 
 #define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_2 \
 	} \
@@ -148,7 +148,7 @@
 
 #define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE \
 	  octave_interrupt_immediately--; \
-          octave_restore_current_context ((char *) saved_context); \
+          octave_restore_current_context (saved_context); \
         } \
     } \
   while (0)
--- a/liboctave/CSparse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/CSparse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -1047,14 +1047,14 @@
       const Complex *Ax = data ();
 
       UMFPACK_ZNAME (report_matrix) (nr, nc, Ap, Ai, 
-				    X_CAST (const double *, Ax), 
-				    NULL, 1, control);
+				     reinterpret_cast<const double *> (Ax), 
+				     NULL, 1, control);
 
       void *Symbolic;
       Matrix Info (1, UMFPACK_INFO);
       double *info = Info.fortran_vec ();
       int status = UMFPACK_ZNAME (qsymbolic) 
-	(nr, nc, Ap, Ai, X_CAST (const double *, Ax), NULL, 
+	(nr, nc, Ap, Ai, reinterpret_cast<const double *> (Ax), NULL, 
 	 NULL, &Symbolic, control, info);
 
       if (status < 0)
@@ -1072,9 +1072,10 @@
 	  UMFPACK_ZNAME (report_symbolic) (Symbolic, control);
 
 	  void *Numeric;
-	  status = UMFPACK_ZNAME (numeric) (Ap, Ai,
-				       X_CAST (const double *, Ax), NULL,
-				       Symbolic, &Numeric, control, info) ;
+	  status
+	    = UMFPACK_ZNAME (numeric) (Ap, Ai,
+				       reinterpret_cast<const double *> (Ax),
+				       NULL, Symbolic, &Numeric, control, info) ;
 	  UMFPACK_ZNAME (free_symbolic) (&Symbolic) ;
 
 	  rcond = Info (UMFPACK_RCOND);
@@ -1097,7 +1098,7 @@
 	      double d_exponent;
 
 	      status = UMFPACK_ZNAME (get_determinant) 
-		(X_CAST (double *, &d[0]), NULL, &d_exponent,
+		(reinterpret_cast<double *> (&d[0]), NULL, &d_exponent,
 		 Numeric, info);
 	      d[1] = d_exponent;
 
@@ -5527,13 +5528,14 @@
   octave_idx_type nc = cols ();
 
   UMFPACK_ZNAME (report_matrix) (nr, nc, Ap, Ai,
-			    X_CAST (const double *, Ax), NULL, 1, control);
+				 reinterpret_cast<const double *> (Ax),
+				 NULL, 1, control);
 
   void *Symbolic;
   Info = Matrix (1, UMFPACK_INFO);
   double *info = Info.fortran_vec ();
   int status = UMFPACK_ZNAME (qsymbolic) (nr, nc, Ap, Ai, 
-				     X_CAST (const double *, Ax), 
+				     reinterpret_cast<const double *> (Ax), 
 				     NULL, NULL, &Symbolic, control, info);
 
   if (status < 0)
@@ -5552,7 +5554,7 @@
       UMFPACK_ZNAME (report_symbolic) (Symbolic, control);
 
       status = UMFPACK_ZNAME (numeric) (Ap, Ai,
-				   X_CAST (const double *, Ax), NULL, 
+				   reinterpret_cast<const double *> (Ax), NULL, 
 				   Symbolic, &Numeric, control, info) ;
       UMFPACK_ZNAME (free_symbolic) (&Symbolic) ;
 
@@ -5641,7 +5643,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
@@ -5806,9 +5808,10 @@
 		{
 #ifdef UMFPACK_SEPARATE_SPLIT
 		  status = UMFPACK_ZNAME (solve) (UMFPACK_A, Ap,
-					     Ai, X_CAST (const double *, Ax), 
+					     Ai,
+					     reinterpret_cast<const double *> (Ax), 
 					     NULL,
-					     X_CAST (double *, &Xx[iidx]), 
+					     reinterpret_cast<double *> (&Xx[iidx]), 
 					     NULL,
 					     &Bx[iidx], Bz, Numeric, 
 					     control, info);
@@ -5817,11 +5820,12 @@
 		    Bz[i] = b.elem (i, j);
 
 		  status = UMFPACK_ZNAME (solve) (UMFPACK_A, Ap,
-					     Ai, X_CAST (const double *, Ax), 
+					     Ai,
+					     reinterpret_cast<const double *> (Ax), 
 					     NULL,
-					     X_CAST (double *, &Xx[iidx]), 
+					     reinterpret_cast<double *>, (&Xx[iidx]), 
 					     NULL,
-					     X_CAST (const double *, Bz),
+					     reinterpret_cast<const double *> (Bz),
 					     NULL, Numeric, 
 					     control, info);
 #endif
@@ -5896,7 +5900,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
@@ -6092,9 +6096,11 @@
 		    Bx[i] = b.elem (i, j);
 
 		  status = UMFPACK_ZNAME (solve) (UMFPACK_A, Ap,
-					     Ai, X_CAST (const double *, Ax),
+					     Ai,
+					     reinterpret_cast<const double *> (Ax),
 					     NULL,
-					     X_CAST (double *, Xx), NULL, 
+					     reinterpret_cast<double *> (Xx),
+					     NULL, 
 					     Bx, Bz, Numeric, control, 
 					     info);
 #else
@@ -6102,10 +6108,12 @@
 		    Bz[i] = b.elem (i, j);
 
 		  status = UMFPACK_ZNAME (solve) (UMFPACK_A, Ap, Ai, 
-					     X_CAST (const double *, Ax),
+					     reinterpret_cast<const double *> (Ax),
 					     NULL,
-					     X_CAST (double *, Xx), NULL, 
-					     X_CAST (double *, Bz), NULL,
+					     reinterpret_cast<double *> (Xx),
+					     NULL,
+					     reinterpret_cast<double *> (Bz),
+					     NULL,
 					     Numeric, control, 
 					     info);
 #endif
@@ -6200,7 +6208,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
@@ -6362,9 +6370,11 @@
 		{
 		  status = 
 		    UMFPACK_ZNAME (solve) (UMFPACK_A, Ap, Ai, 
-				      X_CAST (const double *, Ax), 
-				      NULL, X_CAST (double *, &Xx[iidx]), 
-				      NULL, X_CAST (const double *, &Bx[iidx]), 
+				      reinterpret_cast<const double *> (Ax), 
+				      NULL,
+				      reinterpret_cast<double *> (&Xx[iidx]), 
+				      NULL,
+				      reinterpret_cast<const double *> (&Bx[iidx]), 
 				      NULL, Numeric, control, info);
 		  
 		  if (status < 0)
@@ -6437,7 +6447,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
@@ -6624,9 +6634,12 @@
 		    Bx[i] = b (i,j);
 
 		  status = UMFPACK_ZNAME (solve) (UMFPACK_A, Ap,
-					     Ai, X_CAST (const double *, Ax), 
-					     NULL, X_CAST (double *, Xx), 
-					     NULL, X_CAST (double *, Bx), 
+					     Ai,
+					     reinterpret_cast<const double *> (Ax),
+					     NULL,
+					     reinterpret_cast<double *> (Xx),
+					     NULL,
+					     reinterpret_cast<double *> (Bx),
 					     NULL, Numeric, control, info);
 		  
 		  if (status < 0)
--- a/liboctave/ChangeLog	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/ChangeLog	Fri Apr 14 04:01:40 2006 +0000
@@ -1,3 +1,38 @@
+2006-04-13  David Bateman  <dbateman@free.fr>
+
+        * Sparse.cc (assign (Sparse<LT>&, const Sparse<RT>&)):
+	Optimize assignment.
+
+2006-04-13  John W. Eaton  <jwe@octave.org>
+
+        * Sparse.cc (assign (Sparse<LT>&, const Sparse<RT>&)):
+	Eliminate unnecessary casts.
+	* SparsedbleLU.cc (SparseLU::SparseLU): Likewise.
+
+	* kpse.cc (fopen): Use reinterpret_cast instead of C-style cast.
+	(log_search, dir_links): Use static_cast instead of C-style cast.
+
+	* prog-args.cc (args::getopt): Use reinterpret_cast instead of X_CAST.
+	* oct-alloc.cc (allocator::grow): Likewise.
+	* CSparse.cc (SparseComplexMatrix::determinant,
+	SparseComplexMatrix::factorize, SparseComplexMatrix::fsolve):
+	Likewise.
+	* SparseCmplxLU.cc (SparseComplexLU::SparseComplexLU): Likewise.
+
+	* oct-sort.cc (roundupsize, octave_sort<T>::merge_getmem):
+	Use static_cast instead of C-style cast.
+	* CSparse.cc (SparseComplexMatrix::fsolve): Likewise.
+	* dSparse.cc (SparseMatrix::fsolve): Likewise.
+
+	* data-conv.cc (LS_DO_WRITE): Use static_cast for value conversion.
+	Use OCTAVE_LOCAL_BUFFER instead of new/delete.
+	(LS_DO_READ): Allocate local buffer to avoid pointer tricks.
+	(write_doubles, read_doubles, LS_DO_WRITE, LS_DO_READ):
+	Use reinterpret_cast instead of X_CAST.
+
+	* DiagArray2.h (DiagArray2::Proxy::operator&): No need to cast
+	return value here.
+
 2006-04-12  Rafael Laboissiere  <rafael@debian.org>
 
 	* ArrayN.h (ArrayN::ArrayN): Qualify fill with Array<T> base class.
--- a/liboctave/DiagArray2.h	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/DiagArray2.h	Fri Apr 14 04:01:40 2006 +0000
@@ -94,7 +94,7 @@
     // taking the address of a Proxy.  Maybe it should be implemented
     // by means of a companion function in the DiagArray2 class.
 
-    T *operator& () const { assert (0); return (T *) 0; }
+    T *operator& () const { assert (0); return 0; }
 
     octave_idx_type i;
     octave_idx_type j;
--- a/liboctave/Sparse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/Sparse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -2492,33 +2492,32 @@
 			    {
 			      octave_idx_type iii = 0;
 			      octave_idx_type ii = idx_i.elem (iii);
-			      for (octave_idx_type i = 0; i < new_nr; i++)
+			      octave_idx_type ppp = 0;
+			      octave_idx_type ppi = lhs.cidx(j+1) - 
+				lhs.cidx(j); 
+			      octave_idx_type pp = (ppp < ppi ? 
+						    lhs.ridx(lhs.cidx(j)+ppp) :
+						    new_nr);
+			      while (ppp < ppi || iii < n)
 				{
-				  OCTAVE_QUIT;
-
-				  if (iii < n && ii == i)
+				  if (iii < n && ii <= pp)
 				    {
 				      if (scalar != RT ())
 					{
 					  stmp.data(kk) = scalar;
-					  stmp.ridx(kk++) = i;
+					  stmp.ridx(kk++) = ii;
 					}
+				      if (ii == pp)
+					pp = (++ppp < ppi ? lhs.ridx(lhs.cidx(j)+ppp) : new_nr);					
 				      if (++iii < n)
 					ii = idx_i.elem(iii);
 				    }
-				  else if (j < lhs.cols()) 
+				  else
 				    {
-				      for (octave_idx_type k = lhs.cidx(j); 
-					   k < lhs.cidx(j+1); k++)
-					{
-					  if (lhs.ridx(k) == i)
-					    {
-					      stmp.data(kk) = lhs.data(k);
-					      stmp.ridx(kk++) = i;
-					    }
-					  if (lhs.ridx(k) >= i)
-					    break;
-					}
+				      stmp.data(kk) = 
+					lhs.data(lhs.cidx(j)+ppp);
+				      stmp.ridx(kk++) = pp;
+				      pp = (++ppp < ppi ? lhs.ridx(lhs.cidx(j)+ppp) : new_nr);
 				    }
 				}
 			      if (++jji < m)
@@ -2630,36 +2629,8 @@
 			for (octave_idx_type i = 0; i < m; i++)
 			  rhs_idx_j[i] = i;
 
-		      // Count the number of non-zero terms
-		      octave_idx_type new_nzmx = lhs.nnz ();
-		      for (octave_idx_type j = 0; j < m; j++)
-			{
-			  octave_idx_type jj = idx_j.elem (j);
-			  for (octave_idx_type i = 0; i < n; i++)
-			    {
-			      OCTAVE_QUIT;
-
-			      if (jj < lhs_nc)
-				{
-				  octave_idx_type ii = idx_i.elem (i);
-			      
-				  if (ii < lhs_nr)
-				    {
-				      for (octave_idx_type k = lhs.cidx(jj); 
-					   k < lhs.cidx(jj+1); k++)
-					{
-					  if (lhs.ridx(k) == ii)
-					    new_nzmx--;
-					  if (lhs.ridx(k) >= ii)
-					    break;
-					}
-				    }
-				}
-			      
-			      if (rhs.elem(rhs_idx_i[i],rhs_idx_j[j]) != RT ())
-				new_nzmx++;
-			    }
-			}
+		      // Maximum number of non-zero elements
+		      octave_idx_type new_nzmx = lhs.nnz() + rhs.nnz();
 
 		      Sparse<LT> stmp (new_nr, new_nc, new_nzmx);
 
@@ -2673,35 +2644,34 @@
 			    {
 			      octave_idx_type iii = 0;
 			      octave_idx_type ii = idx_i.elem (iii);
-			      for (octave_idx_type i = 0; i < new_nr; i++)
+			      octave_idx_type ppp = 0;
+			      octave_idx_type ppi = lhs.cidx(j+1) -
+				lhs.cidx(j);
+			      octave_idx_type pp = (ppp < ppi ? 
+						    lhs.ridx(lhs.cidx(j)+ppp) :
+						    new_nr);
+			      while (ppp < ppi || iii < n)
 				{
-				  OCTAVE_QUIT;
-
-				  if (iii < n && ii == i)
+				  if (iii < n && ii <= pp)
 				    {
 				      RT rtmp = rhs.elem (rhs_idx_i[iii], 
 							  rhs_idx_j[jji]);
 				      if (rtmp != RT ())
 					{
 					  stmp.data(kk) = rtmp;
-					  stmp.ridx(kk++) = i;
+					  stmp.ridx(kk++) = ii;
 					}
+				      if (ii == pp)
+					pp = (++ppp < ppi ? lhs.ridx(lhs.cidx(j)+ppp) : new_nr);					
 				      if (++iii < n)
 					ii = idx_i.elem(iii);
 				    }
-				  else if (j < lhs.cols()) 
+				  else
 				    {
-				      for (octave_idx_type k = lhs.cidx(j); 
-					   k < lhs.cidx(j+1); k++)
-					{
-					  if (lhs.ridx(k) == i)
-					    {
-					      stmp.data(kk) = lhs.data(k);
-					      stmp.ridx(kk++) = i;
-					    }
-					  if (lhs.ridx(k) >= i)
-					    break;
-					}
+				      stmp.data(kk) = 
+					lhs.data(lhs.cidx(j)+ppp);
+				      stmp.ridx(kk++) = pp;
+				      pp = (++ppp < ppi ? lhs.ridx(lhs.cidx(j)+ppp) : new_nr);
 				    }
 				}
 			      if (++jji < m)
@@ -2719,6 +2689,7 @@
 			  stmp.cidx(j+1) = kk;
 			}
 
+		      stmp.maybe_compress();
 		      lhs = stmp;
 		    }
 		}
@@ -2788,7 +2759,7 @@
 			}
 		    }
 
-		  if (! assign1 ((Sparse<LT>&) lhs, (Sparse<RT>&) rhs))
+		  if (! assign1 (lhs, rhs))
 		    retval = 0;
 		}
 	    }
@@ -2802,7 +2773,7 @@
 	    {
 	      if (rhs_nr == 0 && rhs_nc == 0)
 		lhs.maybe_delete_elements (idx_i);
-	      else if (! assign1 ((Sparse<LT>&) lhs, (Sparse<RT>&) rhs))
+	      else if (! assign1 (lhs, rhs))
 		retval = 0;
 	    }
 	  // idx_vector::freeze() printed an error message for us.
@@ -2815,7 +2786,7 @@
 	    {
 	      if (rhs_nr == 0 && rhs_nc == 0)
 		lhs.maybe_delete_elements (idx_i);
-	      else if (! assign1 ((Sparse<LT>&) lhs, (Sparse<RT>&) rhs))
+	      else if (! assign1 (lhs, rhs))
 		retval = 0;
 	    }
 	  // idx_vector::freeze() printed an error message for us.
--- a/liboctave/SparseCmplxLU.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/SparseCmplxLU.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -86,14 +86,16 @@
   const Complex *Ax = a.data ();
 
   UMFPACK_ZNAME (report_matrix) (nr, nc, Ap, Ai,
-			    X_CAST (const double *, Ax), NULL, 1, control);
+				 reinterpret_cast<const double *> (Ax),
+				 NULL, 1, control);
 
   void *Symbolic;
   Matrix Info (1, UMFPACK_INFO);
   double *info = Info.fortran_vec ();
   int status = UMFPACK_ZNAME (qsymbolic) (nr, nc, Ap, Ai, 
-				     X_CAST (const double *, Ax), NULL, NULL,
-				     &Symbolic, control, info);
+					  reinterpret_cast<const double *> (Ax),
+					  NULL, NULL,
+					  &Symbolic, control, info);
 
   if (status < 0)
     {
@@ -111,8 +113,9 @@
 
       void *Numeric;
       status = UMFPACK_ZNAME (numeric) (Ap, Ai,
-				   X_CAST (const double *, Ax), NULL, 
-				   Symbolic, &Numeric, control, info) ;
+					reinterpret_cast<const double *> (Ax),
+					NULL, Symbolic, &Numeric, control,
+					info);
       UMFPACK_ZNAME (free_symbolic) (&Symbolic) ;
 
       cond = Info (UMFPACK_RCOND);
@@ -177,10 +180,11 @@
 
 	      octave_idx_type do_recip;
 	      status = UMFPACK_ZNAME (get_numeric) (Ltp, Ltj,
-					       X_CAST (double *, Ltx), NULL, Up, Uj,
-					       X_CAST (double *, Ux), NULL, p, 
-					       q, NULL, NULL, &do_recip,
-					       NULL, Numeric) ;
+						    reinterpret_cast<double *> (Ltx),
+						    NULL, Up, Uj,
+						    reinterpret_cast <double *> (Ux),
+						    NULL, p, q, NULL, NULL,
+						    &do_recip, NULL, Numeric);
 
 	      UMFPACK_ZNAME (free_numeric) (&Numeric) ;
 
@@ -197,12 +201,12 @@
 
 		  UMFPACK_ZNAME (report_matrix) (nr, n_inner,
 					    Lfact.cidx (), Lfact.ridx (), 
-					    X_CAST (double *, Lfact.data()), 
+					    reinterpret_cast<double *> (Lfact.data()), 
 					    NULL, 1, control);
 
 		  UMFPACK_ZNAME (report_matrix) (n_inner, nc,
 					    Ufact.cidx (), Ufact.ridx (), 
-					    X_CAST (double *, Ufact.data()), 
+					    reinterpret_cast<double *> (Ufact.data()), 
 					    NULL, 1, control);
 		  UMFPACK_ZNAME (report_perm) (nr, p, control);
 		  UMFPACK_ZNAME (report_perm) (nc, q, control);
@@ -278,7 +282,7 @@
       const Complex *Ax = a.data ();
 
       UMFPACK_ZNAME (report_matrix) (nr, nc, Ap, Ai, 
-				X_CAST (const double *, Ax), NULL,
+				reinterpret_cast<const double *> (Ax), NULL,
 				1, control);
 
       void *Symbolic;
@@ -295,7 +299,7 @@
 	  qinit [i] = static_cast<octave_idx_type> (Qinit (i));
 
 	status = UMFPACK_ZNAME (qsymbolic) (nr, nc, Ap, Ai, 
-				       X_CAST (const double *, Ax),
+				       reinterpret_cast<const double *> (Ax),
 				       NULL, qinit, &Symbolic, control, 
 				       info);
       } while (0);
@@ -316,7 +320,7 @@
 
 	  void *Numeric;
 	  status = UMFPACK_ZNAME (numeric) (Ap, Ai, 
-				       X_CAST (const double *, Ax), NULL,
+				       reinterpret_cast<const double *> (Ax), NULL,
 				       Symbolic, &Numeric, control, info) ;
 	  UMFPACK_ZNAME (free_symbolic) (&Symbolic) ;
 
@@ -383,9 +387,9 @@
 		  octave_idx_type do_recip;
 		  status = 
 		    UMFPACK_ZNAME (get_numeric) (Ltp, Ltj, 
-					    X_CAST (double *, Ltx),
+					    reinterpret_cast<double *> (Ltx),
 					    NULL, Up, Uj,
-					    X_CAST (double *, Ux), 
+					    reinterpret_cast<double *> (Ux), 
 					    NULL, p, q, NULL, NULL, 
 					    &do_recip, NULL, Numeric) ;
 
@@ -406,13 +410,13 @@
 		      UMFPACK_ZNAME (report_matrix) (nr, n_inner, 
 						Lfact.cidx (), 
 						Lfact.ridx (), 
-						X_CAST (double *, Lfact.data()), 
+						reinterpret_cast<double *> (Lfact.data()), 
 						NULL, 1, control);
 
 		      UMFPACK_ZNAME (report_matrix) (n_inner, nc, 
 						Ufact.cidx (), 
 						Ufact.ridx (), 
-						X_CAST (double *, Ufact.data()), 
+						reinterpret_cast<double *> (Ufact.data()), 
 						NULL, 1, control);
 		      UMFPACK_ZNAME (report_perm) (nr, p, control);
 		      UMFPACK_ZNAME (report_perm) (nc, q, control);
--- a/liboctave/SparsedbleLU.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/SparsedbleLU.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -174,8 +174,8 @@
 
 	      octave_idx_type do_recip;
 	      status = UMFPACK_DNAME (get_numeric) (Ltp, Ltj, Ltx,
-					       Up, Uj, Ux, p, q, (double *) NULL,
-					       &do_recip, (double *) NULL, 
+					       Up, Uj, Ux, p, q, NULL,
+					       &do_recip, NULL, 
 					       Numeric) ;
 
 	      UMFPACK_DNAME (free_numeric) (&Numeric) ;
@@ -371,10 +371,8 @@
 		  octave_idx_type do_recip;
 		  status = UMFPACK_DNAME (get_numeric) (Ltp, Ltj,
 						   Ltx, Up, Uj, Ux, p, q, 
-						   (double *) NULL,
-						   &do_recip, 
-						   (double *) NULL, 
-						   Numeric) ;
+						   NULL, &do_recip, 
+						   NULL, Numeric) ;
 
 		  UMFPACK_DNAME (free_numeric) (&Numeric) ;
 
--- a/liboctave/dSparse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/dSparse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -5862,7 +5862,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
@@ -6093,7 +6093,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
@@ -6372,7 +6372,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
@@ -6623,7 +6623,7 @@
 	    }
 	  else
 	    {
-	      cm->print = (int)spu + 2;
+	      cm->print = static_cast<int> (spu) + 2;
 	      cm->print_function =&SparseCholPrint;
 	    }
 
--- a/liboctave/data-conv.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/data-conv.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -28,6 +28,7 @@
 #include <cctype>
 
 #include <iostream>
+#include <vector>
 
 #include "byte-swap.h"
 #include "data-conv.h"
@@ -469,14 +470,12 @@
     { \
       if (len > 0) \
 	{ \
-	  volatile TYPE *ptr = X_CAST (volatile TYPE *, data); \
-	  stream.read (X_CAST (char *, ptr), size * len); \
+	  OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
+	  stream.read (reinterpret_cast<char *>  (ptr), size * len); \
 	  if (swap) \
 	    swap_bytes< size > (ptr, len); \
-	  TYPE tmp = ptr[0]; \
-	  for (int i = len - 1; i > 0; i--) \
+	  for (int i = 0; i < len; i++) \
 	    data[i] = ptr[i]; \
-	  data[0] = tmp; \
 	} \
     } \
   while (0)
@@ -489,13 +488,12 @@
     { \
       if (len > 0) \
 	{ \
-	  char tmp_type = static_cast<char> (type); \
+	  char tmp_type = type; \
 	  stream.write (&tmp_type, 1); \
-	  TYPE *ptr = new TYPE [len]; \
+	  OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
 	  for (int i = 0; i < len; i++) \
-	    ptr[i] = X_CAST (TYPE, data[i]); \
-	  stream.write (X_CAST (char *, ptr), size * len); \
-	  delete [] ptr ; \
+	    ptr[i] = static_cast <TYPE> (data[i]);	   \
+	  stream.write (reinterpret_cast<char *> (ptr), size * len); \
 	} \
     } \
   while (0)
@@ -1027,18 +1025,16 @@
 
     case LS_FLOAT:
       {
-	volatile float *ptr = X_CAST (float *, data);
-	is.read (X_CAST (char *, data), 4 * len);
-	do_float_format_conversion (data, len, fmt);
-	float tmp = ptr[0];
-	for (int i = len - 1; i > 0; i--)
+	OCTAVE_LOCAL_BUFFER (float, ptr, len);
+	is.read (reinterpret_cast<char *> (ptr), 4 * len);
+	do_float_format_conversion (ptr, len, fmt);
+	for (int i = 0; i < len; i++)
 	  data[i] = ptr[i];
-	data[0] = tmp;
       }
       break;
 
     case LS_DOUBLE: // No conversion necessary.
-      is.read (X_CAST (char *, data), 8 * len);
+      is.read (reinterpret_cast<char *> (data), 8 * len);
       do_double_format_conversion (data, len, fmt);
       break;
 
@@ -1083,9 +1079,9 @@
 
     case LS_DOUBLE: // No conversion necessary.
       {
-	char tmp_type = X_CAST (char, type);
+	char tmp_type = static_cast<char> (type);
 	os.write (&tmp_type, 1);
-	os.write (X_CAST (char *, data), 8 * len);
+	os.write (reinterpret_cast <const char *> (data), 8 * len);
       }
       break;
 
--- a/liboctave/kpse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/kpse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -678,7 +678,8 @@
 
 	  /* Only record absolute filenames, for privacy.  */
 	  if (log_file && kpse_absolute_p (filename.c_str (), false))
-	    fprintf (log_file, "%lu %s\n", (long unsigned) time (0),
+	    fprintf (log_file, "%lu %s\n",
+		     static_cast<unsigned long> (time (0)),
 		     filename.c_str ());
 
 	  /* And show them online, if debugging.  We've already started
@@ -2139,7 +2140,7 @@
       struct stat stats;
 
       ret = stat (fn.c_str (), &stats) == 0 && S_ISDIR (stats.st_mode)
-            ? stats.st_nlink : (unsigned) -1;
+	? stats.st_nlink : static_cast<unsigned> (-1);
 
       link_table[fn] = ret;
 
@@ -2418,7 +2419,8 @@
   FILE *ret = fopen (filename, mode);
 
   if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN))
-    DEBUGF3 ("fopen (%s, %s) => 0x%lx\n", filename, mode, (unsigned long) ret);
+    DEBUGF3 ("fopen (%s, %s) => 0x%lx\n", filename, mode,
+	     reinterpret_cast<unsigned long> (ret));
 
   return ret;
 }
--- a/liboctave/oct-alloc.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/oct-alloc.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -79,13 +79,14 @@
       while (p < last)
 	{
 	  char *next = p + item_size;
-	  (X_CAST (link *, p)) -> next = X_CAST (link *, next);
+	  (reinterpret_cast<link *> (p)) -> next
+	    = reinterpret_cast<link *> (next);
 	  p = next;
 	}
 
-      (X_CAST (link *, last)) -> next = 0;
+      (reinterpret_cast<link *> (last)) -> next = 0;
 
-      head = X_CAST (link *, start);
+      head = reinterpret_cast<link *> (start);
     }
   else
     {
--- a/liboctave/oct-sort.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/oct-sort.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -437,7 +437,7 @@
 roundupsize(int n)
 {
   unsigned int nbits = 3;
-  unsigned int n2 = (unsigned int)n >> 8;
+  unsigned int n2 = static_cast<unsigned int> (n) >> 8;
 
   /* Round up:
    * If n <       256, to a multiple of        8.
@@ -483,7 +483,7 @@
    * we don't care what's in the block.
    */
   merge_freemem( );
-  ms.a = (T *) malloc (need * sizeof (T));
+  ms.a = static_cast <T *> (malloc (need * sizeof (T)));
   if (ms.a) {
     ms.alloced = need;
     return 0;
--- a/liboctave/prog-args.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/prog-args.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -33,8 +33,9 @@
 prog_args::getopt (void)
 {
   if (long_opts)
-    return ::octave_getopt_long (xargc, xargv, short_opts,
-				 X_CAST (const struct option *, long_opts), 0);
+    return ::octave_getopt_long
+      (xargc, xargv, short_opts,
+       reinterpret_cast<const struct option *> (long_opts), 0);
   else
     return ::octave_getopt (xargc, xargv, short_opts);
 }
--- a/liboctave/sparse-base-chol.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/sparse-base-chol.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -107,7 +107,7 @@
     }
   else
     {
-      cm->print = (int)spu + 2;
+      cm->print = static_cast<int> (spu) + 2;
       cm->print_function =&SparseCholPrint;
     }
 
--- a/liboctave/str-vec.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/liboctave/str-vec.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -71,8 +71,8 @@
 int
 string_vector::compare (const void *a_arg, const void *b_arg)
 {
-  const std::string *a = (const std::string *) a_arg;
-  const std::string *b = (const std::string *) b_arg;
+  const std::string *a = static_cast<const std::string *>  (a_arg);
+  const std::string *b = static_cast<const std::string *> (b_arg);
 
   return a->compare (*b);
 }
--- a/src/ChangeLog	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ChangeLog	Fri Apr 14 04:01:40 2006 +0000
@@ -1,5 +1,161 @@
 2006-04-13  John W. Eaton  <jwe@octave.org>
 
+	* Makefile.in (lex.o parse.o pic/lex.o pic/parse.o): Omit
+	-Wold-style-cast from CXXFLAGS.
+
+	* ls-mat5.cc (READ_INTEGER_DATA): Allocate local buffer to avoid
+	pointer tricks.
+
+	* DLD-FUNCTIONS/regexp.cc (octregexp): Use OCTAVE_LOCAL_BUFFER
+	instead of allocting memory with malloc.
+
+	* DLD-FUNCTIONS/sparse.cc (Fsparse): Use octave_value extractors
+	instead of using get_rep.
+
+	* DLD-FUNCTIONS/dispatch.cc (dispatch_record): Use dynamic_cast,
+	not reinterpret_cast.
+
+	* DLD-FUNCTIONS/besselj.cc (Fairy): Use int_value instead of
+	double_value and cast to extract kind arg.
+	(int_arrayN_to_array): Arg is ArrayN<octave_idx_type>, not ArrayN<int>.
+
+	* OPERATORS/op-cm-scm.cc, OPERATORS/op-cm-sm.cc,
+	OPERATORS/op-cs-scm.cc, OPERATORS/op-cs-sm.cc,
+	OPERATORS/op-m-scm.cc, OPERATORS/op-m-sm.cc,
+	OPERATORS/op-s-scm.cc, OPERATORS/op-s-sm.cc,
+	OPERATORS/op-scm-cm.cc, OPERATORS/op-scm-cs.cc,
+	OPERATORS/op-scm-m.cc, OPERATORS/op-scm-s.cc,
+	OPERATORS/op-scm-scm.cc, OPERATORS/op-scm-sm.cc,
+	OPERATORS/op-sm-cm.cc, OPERATORS/op-sm-cs.cc,
+	OPERATORS/op-sm-m.cc, OPERATORS/op-sm-s.cc,
+	OPERATORS/op-sm-scm.cc, OPERATORS/op-sm-sm.cc: No need to cast
+	away const just to cache sparse type.
+	* ov-base-sparse.h (octave_base_sparse::typ): Now mutable.
+	(octave_base_sparse::sparse_type): Now const.
+
+	* OPERATORS/op-cm-scm.cc (DEFBINOP(div)): Explicitly cast args
+	here instead of using CAST_BINOP_ARGS.
+
+	* OPERATORS/op-streamoff.cc (STREAMOFF_COMP_OP): Second arg to 
+	CAST_BINOP_ARGS is also const.
+
+	* DLD-FUNCTIONS/chol.cc (Fcholinv, Fchol2inv): Eliminate nargout
+	arg to avoid unused variable warnings.
+
+	* unwind-prot.h, unwind-prot.cc (unwind_protect::save_bool,
+	unwind_protect::save_int, unwind_protect::save_str,
+	unwind_protect::save_ptr, unwind_protect::save_var):
+	Pointer args now const.
+	(unwind_protect_const_ptr): New macro.
+
+	* symtab.cc (maybe_list_cmp_fcn): Use static_cast instead of X_CAST.
+	* variables.cc (symbol_record_name_compare): Likewise.
+	* ls-mat5.cc (MAT5_DO_WRITE, save_mat5_binary_element): Likewise.
+
+	* ov-fcn-handle.cc (octave_fcn_handle::save_hdf5,
+	octave_fcn_handle::load_hdf5): Eliminate unnecessary casts.
+	* ov-fcn-inline.cc (octave_fcn_inline::save_hdf5,
+	octave_fcn_inline::load_hdf5): Likewise.
+	* ov-str-mat.cc (octave_char_matrix_str::save_hdf5,
+	octave_char_matrix_str::load_hdf5): Likewise.
+	* ov-bool-sparse.cc (octave_sparse_bool_matrix::save_hdf5,
+	octave_sparse_bool_matrix::load_hdf5): Likewise.
+	* ov-cx-sparse.cc (octave_sparse_complex_matrix::save_hdf5,
+	octave_sparse_complex_matrix::load_hdf5): Likewise.
+	* ov-re-sparse.cc (octave_sparse_matrix::save_hdf5,
+	octave_sparse_matrix::load_hdf5): Likewise.
+	* ov-str-mat.cc (octave_char_matrix_str::save_ascii,
+	octave_char_matrix_str::load_ascii): Likewise.
+	* mappers.cc (xtoascii): Likewise.
+	* load-save.cc (read_binary_file_header, write_header): Likewise.
+	* parse.y (get_help_from_file, parse_fcn_file): Likewise.
+	* DLD-FUNCTIONS/rand.cc (do_rand): Likewise.
+	* ls-hdf5.cc (read_hdf5_data, hdf5_add_attr, save_hdf5_empty,
+	load_hdf5_empty add_hdf5_data): Likewise.
+	* ls-mat4.cc (read_mat_binary_data): Likewise.
+	* ls-mat5.cc (read_mat5_binary_element): Likewise.
+
+	* oct-stream.cc (expand_char_class, octave_base_stream::do_gets):
+	Use static_cast instead of C-style cast.
+	* oct-procbuf.cc (kluge_procbuf_delay): Likewise.
+	* parse.y (gobble_leading_white_space,: Likewise.
+	* DLD-FUNCTIONS/besselj.cc (int_array2_to_matrix,
+	int_arrayN_to_array): Likewise.
+	* DLD-FUNCTIONS/colamd.cc (Fcolamd, Fsymamd): Likewise.
+	* DLD-FUNCTIONS/ccolamd.cc (Fcsymamd): Likewise.
+	* pt-pr-code.cc (tree_print_code::print_comment_elt): Likewise.
+	* DLD-FUNCTIONS/besselj.cc (do_bessel): Likewise.
+	* DLD-FUNCTIONS/spchol.cc (Fsymfact): Likewise.
+	* DLD-FUNCTIONS/sparse.cc (sparse_find): Likewise.
+	* DLD-FUNCTIONS/sort.cc (FloatFlip): Likewise.
+	* DLD-FUNCTIONS/matrix_type.cc (Fmatrix_type): Likewise.
+	* ls-mat5.cc (read_mat5_binary_element, OCTAVE_MAT5_INTEGER_READ,
+	read_mat5_binary_element, save_mat5_binary_element): Likewise.
+
+	* DLD-FUNCTIONS/splu.cc (Fspinv): Use dynamic_cast instead of
+	C-style cast.
+	* DLD-FUNCTIONS/matrix_type.cc (Fmatrix_type): Likewise.
+
+	* DLD-FUNCTIONS/sort.cc (mx_sort): Use reinterpret_cast instead of
+	C-style cast.
+	* ls-mat5.cc (write_mat5_tag): Likewise.
+
+	* ov-typeinfo.h (octave_value_typeinfo::octave_value_typeinfo):
+	Eliminate unnecessary casts in constructor initializers.
+
+	* ops.h (CAST_CONV_ARG, CAST_UNOP_ARG, CAST_BINOP_ARGS,
+	DEFASSIGNANYOP_FN): Use C++ dynamic_cast instead of DYNAMIC_CAST macro.
+
+	* unwind-prot.h (unwind_protect_ptr): Use combination of
+	reinterpret_cast and const_cast instead of X_CAST.
+
+	* dynamic-ld.cc (loader::do_load): Use reinterpret_cast instead of
+	X_CAST.
+	* ov-base-int.cc (octave_base_int_matrix<T>::save_binary,
+	octave_base_int_matrix<T>::load_binary,
+	octave_base_int_scalar<T>::save_binary,
+	octave_base_int_scalar<T>::load_binary): Likewise.
+	* ov-bool-mat.cc (octave_bool_matrix::save_binary,
+	octave_bool_matrix::load_binary): Likewise.
+	* ov-bool-sparse.cc (octave_sparse_bool_matrix::save_binary,
+	octave_sparse_bool_matrix::load_binary): Likewise.
+	* ov-bool.cc (octave_bool::save_binary, octave_bool::load_binary):
+	Likewise.
+	* ov-cell.cc (octave_cell::save_binary, octave_cell::load_binary):
+	Likewise.
+	* ov-complex.cc (octave_complex::save_binary,
+	octave_complex::load_binary): Likewise.
+	* ov-cx-mat.cc (octave_matrix::save_binary,
+	octave_matrix::load_binary): Likewise.
+	* ov-cx-sparse.cc (octave_sparse_complex_matrix::save_binary,
+	octave_sparse_complex_matrix::load_binary): Likewise.
+	* ov-fcn-handle.cc (octave_fcn_handle::save_binary,
+	octave_fcn_handle::load_binary): Likewise.
+	* ov-fcn-inline.cc (octave_fcn_inline::save_binary,
+	octave_fcn_inline::load_binary): Likewise.
+	* ov-list.cc (octave_list::save_binary, octave_list::load_binary):
+	Likewise.
+	* ov-range.cc (octave_range::save_binary, octave_range::load_binary): 
+	Likewise.
+	* ov-re-mat.cc (octave_matrix::save_binary,
+	octave_matrix::load_binary): Likewise.
+	* ov-re-sparse.cc (octave_sparse_matrix::save_binary,
+	octave_sparse_matrix::load_binary): Likewise.
+	* ov-scalar.cc (octave_scalar::save_binary,
+	octave_scalar::load_binary): Likewise.
+	* ov-str-mat.cc (octave_char_matrix_str::save_binary,
+	(octave_char_matrix_str::load_binary): Likewise.
+	* ov-struct.cc (octave_struct::save_binary,
+	octave_struct::load_binary): Likewise.
+	* ls-oct-binary.cc (save_binary_data, read_binary_data): Likewise.
+	* ls-mat4.cc (read_mat_file_header, save_mat_binary_data): Likewise.
+	* ls-mat5.cc (read_mat5_tag, read_mat5_binary_element,
+	read_mat5_binary_element, read_mat5_binary_file_header,
+	MAT5_DO_WRITE, write_mat5_array, write_mat5_integer_data,
+	save_mat5_binary_element, READ_INTEGER_DATA): Likewise.
+
+2006-04-12  John W. Eaton  <jwe@octave.org>
+
 	* ov.h (OV_REP_TYPE): New macro.
 
 	* DLD-FUNCTIONS/sparse.cc (MINMAX_BODY): No need to cast arg1 to
--- a/src/DLD-FUNCTIONS/besselj.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/besselj.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -92,14 +92,14 @@
       {
 	OCTAVE_QUIT;
 
-	retval(i,j) = (double) (a(i,j));
+	retval(i,j) = static_cast<double> (a(i,j));
       }
 
   return retval;
 }
 
 static inline NDArray
-int_arrayN_to_array (const ArrayN<int>& a)
+int_arrayN_to_array (const ArrayN<octave_idx_type>& a)
 {
   dim_vector dv = a.dims ();
   int nel = dv.numel ();
@@ -110,7 +110,7 @@
     {
       OCTAVE_QUIT;
       
-      retval(i) = (double) (a(i));
+      retval(i) = static_cast<double> (a(i));
     }
 
   return retval;
@@ -155,7 +155,7 @@
 		      DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
 		      if (nargout > 1)
-			retval(1) = (double) ierr;
+			retval(1) = static_cast<double> (ierr);
 
 		      retval(0) = result;
 		    }
@@ -463,12 +463,10 @@
 
       if (nargin > 1)
 	{
-	  double d_kind = args(0).double_value ();
+	  kind = args(0).int_value ();
 
 	  if (! error_state)
 	    {
-	      kind = (int) d_kind;
-
 	      if (kind < 0 || kind > 3)
 		error ("airy: expecting K = 0, 1, 2, or 3");
 	    }	      
--- a/src/DLD-FUNCTIONS/ccolamd.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/ccolamd.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -410,7 +410,7 @@
 	  if (nel_User_knobs > 0) 
 	    knobs [CCOLAMD_AGGRESSIVE] = User_knobs (1);
 	  if (nel_User_knobs > 1) 
-	    spumoni = (int) User_knobs (2);
+	    spumoni = static_cast<int> (User_knobs (2));
 
 	  // print knob settings if spumoni is set
 	  if (spumoni)
--- a/src/DLD-FUNCTIONS/chol.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/chol.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -118,7 +118,7 @@
   return retval;
 }
 
-DEFUN_DLD (cholinv, args, nargout,
+DEFUN_DLD (cholinv, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {} cholinv (@var{a})\n\
 Use the Cholesky factorization to compute the inverse of the\n\
@@ -179,7 +179,7 @@
   return retval;
 }
 
-DEFUN_DLD (chol2inv, args, nargout,
+DEFUN_DLD (chol2inv, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {} chol2inv (@var{u})\n\
 Invert a symmetric, positive definite square matrix from its Cholesky\n\
--- a/src/DLD-FUNCTIONS/colamd.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/colamd.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -292,7 +292,7 @@
 	  if (nel_User_knobs > 1) 
 	    knobs [COLAMD_DENSE_COL] = User_knobs (1) ;
 	  if (nel_User_knobs > 2) 
-	    spumoni = (int) User_knobs (2);
+	    spumoni = static_cast<int> (User_knobs (2));
 
 	  // print knob settings if spumoni is set
 	  if (spumoni)
@@ -526,7 +526,7 @@
 	  if (nel_User_knobs > 0) 
 	    knobs [COLAMD_DENSE_ROW] = User_knobs (COLAMD_DENSE_ROW);
 	  if (nel_User_knobs > 1) 
-	    spumoni = (int) User_knobs (1);
+	    spumoni = static_cast<int> (User_knobs (1));
 	}
 
       // print knob settings if spumoni is set
--- a/src/DLD-FUNCTIONS/dispatch.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/dispatch.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -398,7 +398,7 @@
 
   // clear/replace/extend the map with the new type-function pair
   const octave_dispatch& rep
-    = reinterpret_cast<const octave_dispatch&> (sr->def().get_rep ());
+    = dynamic_cast<const octave_dispatch&> (sr->def().get_rep ());
 
   if (t.empty ())
     // XXX FIXME XXX should return the list if nargout > 1
--- a/src/DLD-FUNCTIONS/matrix_type.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/matrix_type.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -112,12 +112,13 @@
 	  if (nargin == 1)
 	    {
 	      SparseType mattyp;
-	      const octave_base_value& rep = args(0).get_rep ();
 
 	      if (args(0).type_name () == "sparse complex matrix" ) 
 		{
-		  mattyp = 
-		    ((const octave_sparse_complex_matrix &)rep).sparse_type ();
+		  const octave_sparse_complex_matrix& rep
+		    = dynamic_cast<const octave_sparse_complex_matrix&> (args(0).get_rep ());
+
+		  mattyp = rep.sparse_type ();
 
 		  if (mattyp.is_unknown ())
 		    {
@@ -126,13 +127,16 @@
 		      if (!error_state)
 			{
 			  mattyp = SparseType (m);
-			    ((octave_sparse_complex_matrix &)rep).sparse_type (mattyp);
+			  rep.sparse_type (mattyp);
 			}
 		    }
 		}
 	      else
 		{
-		  mattyp = ((const octave_sparse_matrix &)rep).sparse_type ();
+		  const octave_sparse_matrix& rep
+		    = dynamic_cast<const octave_sparse_matrix&> (args(0).get_rep ());
+
+		  mattyp = rep.sparse_type ();
 
 		  if (mattyp.is_unknown ())
 		    {
@@ -140,7 +144,7 @@
 		      if (!error_state)
 			{
 			  mattyp = SparseType (m);
-			  ((octave_sparse_matrix &)rep).sparse_type (mattyp);
+			  rep.sparse_type (mattyp);
 			}
 		    }
 		}
@@ -267,7 +271,7 @@
 				  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
 
 				  for (octave_idx_type i = 0; i < len; i++)
-				    p[i] = (octave_idx_type) (perm (i)) - 1; 
+				    p[i] = static_cast<octave_idx_type> (perm (i)) - 1; 
 
 				  if (str_typ == "upper")
 				    mattyp.mark_as_permuted (len, p);
--- a/src/DLD-FUNCTIONS/rand.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/rand.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -250,7 +250,7 @@
 
 	    for (int i = 0; i < nargin; i++)
 	      {
-		dims(i) = (octave_idx_type)args(idx+i).int_value ();
+		dims(i) = args(idx+i).int_value ();
 
 		if (error_state)
 		  {
--- a/src/DLD-FUNCTIONS/regexp.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/regexp.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -313,18 +313,10 @@
       if (err)
 	{
 	  int len = regerror(err, &compiled, NULL, 0);
-	  char *errmsg = (char *)malloc(len);
-	  if (errmsg)
-	    {
-	      regerror(err, &compiled, errmsg, len);
-	      error("%s: %s in pattern (%s)", nm.c_str(), errmsg, 
-		    pattern.c_str());
-	      free(errmsg);
-	    }
-	  else
-	    {
-	      error("out of memory");
-	    }
+	  OCTAVE_LOCAL_BUFFER (char, errmsg, len);
+	  regerror(err, &compiled, errmsg, len);
+	  error("%s: %s in pattern (%s)", nm.c_str(), errmsg, 
+		pattern.c_str());
 	  regfree(&compiled);
 	  return retval;
 	}
--- a/src/DLD-FUNCTIONS/sort.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/sort.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -246,7 +246,7 @@
 FloatFlip (unsigned EIGHT_BYTE_INT f)
 {
   unsigned EIGHT_BYTE_INT mask
-    = -(EIGHT_BYTE_INT)(f >> 63) | 0x8000000000000000ULL;
+    = -static_cast<EIGHT_BYTE_INT>(f >> 63) | 0x8000000000000000ULL;
 
   return f ^ mask;
 }
@@ -350,7 +350,7 @@
 	    if (mode == UNDEFINED || mode == ASCENDING)
 	      {
 		octave_idx_type i = 0;
-		double *vtmp = (double *)p;
+		double *vtmp = reinterpret_cast<double *> (p);
 		while (xisnan (vtmp[i++]) && i < ns);
 		for (octave_idx_type l = 0; l < ns - i + 1; l++)
 		  vtmp[l] = vtmp[l+i-1];
@@ -360,7 +360,7 @@
 	    else
 	      {
 		octave_idx_type i = ns;
-		double *vtmp = (double *)p;
+		double *vtmp = reinterpret_cast<double *> (p);
 		while (xisnan (vtmp[--i]) && i > 0);
 		for (octave_idx_type l = i; l >= 0; l--)
 		  vtmp[l-i+ns-1] = vtmp[l];
--- a/src/DLD-FUNCTIONS/sparse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/sparse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -149,23 +149,17 @@
 	 {
 	   if (use_complex) 
 	     {
-	       SparseComplexMatrix sm (((const octave_sparse_complex_matrix&) arg
-					.get_rep ())
-				       .sparse_complex_matrix_value ());
+	       SparseComplexMatrix sm = arg.sparse_complex_matrix_value ();
 	       retval = new octave_sparse_complex_matrix (sm);
 	     }
 	   else if (use_bool) 
 	     {
-	       SparseBoolMatrix sm (((const octave_sparse_bool_matrix&) arg
-					.get_rep ())
-				       .sparse_bool_matrix_value ());
+	       SparseBoolMatrix sm = arg.sparse_bool_matrix_value ();
 	       retval = new octave_sparse_bool_matrix (sm);
 	     }
 	   else
 	     {
-	       SparseMatrix sm (((const octave_sparse_matrix&) arg
-				 .get_rep ())
-				.sparse_matrix_value ());
+	       SparseMatrix sm = arg.sparse_matrix_value ();
 	       retval = new octave_sparse_matrix (sm);
 	     }
 	 }
@@ -380,10 +374,11 @@
 {
   octave_value retval;
 
-  if (args.length() < 1) {
-     print_usage ("full");
-     return retval;
-  }
+  if (args.length() < 1)
+    {
+      print_usage ("full");
+      return retval;
+    }
 
   if (args(0).is_sparse_type ())
     {
@@ -430,18 +425,19 @@
 
   if (dv(0) == 1)
     {
-      retval(0)= I.transpose ();
-      retval(1)= J.transpose ();
-      retval(2)= S.transpose ();
+      retval(0) = I.transpose ();
+      retval(1) = J.transpose ();
+      retval(2) = S.transpose ();
     }
   else
     {
-      retval(0)= I;
-      retval(1)= J;
-      retval(2)= S;
+      retval(0) = I;
+      retval(1) = J;
+      retval(2) = S;
     }
-  retval(3)= (double) nr;
-  retval(4)= (double) nc;
+  retval(3) = static_cast<double> (nr);
+  retval(4) = static_cast<double> (nc);
+
   return retval;
 }
 
@@ -471,18 +467,19 @@
 
   if (dv(0) == 1)
     {
-      retval(0)= I.transpose ();
-      retval(1)= J.transpose ();
-      retval(2)= S.transpose ();
+      retval(0) = I.transpose ();
+      retval(1) = J.transpose ();
+      retval(2) = S.transpose ();
     }
   else
     {
-      retval(0)= I;
-      retval(1)= J;
-      retval(2)= S;
+      retval(0) = I;
+      retval(1) = J;
+      retval(2) = S;
     }
-  retval(3)= (double) nr;
-  retval(4)= (double) nc;
+  retval(3) = static_cast<double> (nr);
+  retval(4) = static_cast<double> (nc);
+
   return retval;
 }
 
@@ -512,18 +509,19 @@
 
   if (dv(0) == 1)
     {
-      retval(0)= I.transpose ();
-      retval(1)= J.transpose ();
-      retval(2)= S.transpose ();
+      retval(0) = I.transpose ();
+      retval(1) = J.transpose ();
+      retval(2) = S.transpose ();
     }
   else
     {
-      retval(0)= I;
-      retval(1)= J;
-      retval(2)= S;
+      retval(0) = I;
+      retval(1) = J;
+      retval(2) = S;
     }
-  retval(3)= (double) nr;
-  retval(4)= (double) nc;
+  retval(3) = static_cast<double> (nr);
+  retval(4) = static_cast<double> (nc);
+
   return retval;
 }
 
--- a/src/DLD-FUNCTIONS/spchol.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/spchol.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -406,7 +406,7 @@
     }
   else
     {
-      cm->print = (int)spu + 2;
+      cm->print = static_cast<int> (spu) + 2;
       cm->print_function =&SparseCholPrint;
     }
 
@@ -652,7 +652,7 @@
 	  for (int i = 0 ; i < n ; i++)
 	    height = (height > Level[i] ? height : Level[i]);
 	  height++ ;
-	  retval(1) = (double)height;
+	  retval(1) = static_cast<double> (height);
 	}
 
       for (octave_idx_type i = 0; i < n; i++)
--- a/src/DLD-FUNCTIONS/splu.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/DLD-FUNCTIONS/splu.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -421,7 +421,6 @@
     }
 
   octave_value arg = args(0);
-  const octave_base_value& rep = arg.get_rep ();
 
   octave_idx_type nr = arg.rows ();
   octave_idx_type nc = arg.columns ();
@@ -446,11 +445,16 @@
 
       if (! error_state)
 	{
+	  const octave_sparse_matrix& rep
+	    = dynamic_cast<const octave_sparse_matrix&> (arg.get_rep ());
+
+	  SparseType mattyp = rep.sparse_type ();
+
 	  octave_idx_type info;
 	  double rcond = 0.0;
-	  SparseType mattyp = ((octave_sparse_matrix &)rep).sparse_type ();
 	  SparseMatrix result = m.inverse (mattyp, info, rcond, 1);
-	  ((octave_sparse_matrix &)(arg.get_rep())).sparse_type (mattyp);
+
+	  rep.sparse_type (mattyp);
 
 	  if (nargout > 1)
 	    retval(1) = rcond;
@@ -470,13 +474,16 @@
 
       if (! error_state)
 	{
+	  const octave_sparse_complex_matrix& rep
+	    = dynamic_cast<const octave_sparse_complex_matrix&> (arg.get_rep ());
+	  SparseType mattyp = rep.sparse_type ();
+
 	  octave_idx_type info;
 	  double rcond = 0.0;
 
-	  SparseType mattyp = 
-	    ((octave_sparse_complex_matrix &)rep).sparse_type ();
 	  SparseComplexMatrix result = m.inverse (mattyp, info, rcond, 1);
-	  ((octave_sparse_matrix &)rep).sparse_type (mattyp);
+
+	  rep.sparse_type (mattyp);
 
 	  if (nargout > 1)
 	    retval(1) = rcond;
--- a/src/Makefile.in	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/Makefile.in	Fri Apr 14 04:01:40 2006 +0000
@@ -266,6 +266,8 @@
 
 objects: $(OBJECTS)
 
+lex.o parse.o pic/lex.o pic/parse.o : ALL_CXXFLAGS := $(filter-out -Wold-style-cast, $(ALL_CXXFLAGS))
+
 XERBLA = ../libcruft/blas-xtra/xerbla.o
 ifdef FPICFLAG
   PIC_XERBLA = ../libcruft/blas-xtra/pic/xerbla.o
--- a/src/OPERATORS/op-cm-scm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-cm-scm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -47,7 +47,8 @@
 
 DEFBINOP (div, complex_matrix, sparse_complex_matrix)
 {
-  CAST_BINOP_ARGS (const octave_complex_matrix&, octave_sparse_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_complex_matrix&,
+		   const octave_sparse_complex_matrix&);
   
   SparseType typ = v2.sparse_type ();
 
--- a/src/OPERATORS/op-cm-sm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-cm-sm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -47,7 +47,7 @@
 
 DEFBINOP (div, complex_matrix, sparse_matrix)
 {
-  CAST_BINOP_ARGS (const octave_complex_matrix&, octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_sparse_matrix&);
   
   SparseType typ = v2.sparse_type ();
 
--- a/src/OPERATORS/op-cs-scm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-cs-scm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -45,7 +45,7 @@
 
 DEFBINOP (div, complex, sparse_complex_matrix)
 {
-  CAST_BINOP_ARGS (const octave_complex&, octave_sparse_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_complex&, const octave_sparse_complex_matrix&);
 
   SparseType typ = v2.sparse_type ();
   ComplexMatrix m1 = ComplexMatrix (1, 1, v1.complex_value ());
--- a/src/OPERATORS/op-cs-sm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-cs-sm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -47,7 +47,7 @@
 
 DEFBINOP (div, complex, sparse_matrix)
 {
-  CAST_BINOP_ARGS (const octave_complex&, octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_complex&, const octave_sparse_matrix&);
 
   SparseType typ = v2.sparse_type ();
   ComplexMatrix m1 = ComplexMatrix (1, 1, v1.complex_value ());
--- a/src/OPERATORS/op-m-scm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-m-scm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -48,7 +48,7 @@
 
 DEFBINOP (div, matrix, sparse_complex_matrix)
 {
-  CAST_BINOP_ARGS (const octave_matrix&, octave_sparse_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_matrix&, const octave_sparse_complex_matrix&);
 
   SparseType typ = v2.sparse_type ();
 
--- a/src/OPERATORS/op-m-sm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-m-sm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -47,7 +47,7 @@
 
 DEFBINOP (div, matrix, sparse_matrix)
 {
-  CAST_BINOP_ARGS (const octave_matrix&, octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_matrix&, const octave_sparse_matrix&);
   SparseType typ = v2.sparse_type ();
 
   Matrix ret = xdiv (v1.matrix_value (), v2.sparse_matrix_value (), typ);
--- a/src/OPERATORS/op-s-scm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-s-scm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -48,7 +48,7 @@
 
 DEFBINOP (div, scalar, sparse_complex_matrix)
 {
-  CAST_BINOP_ARGS (const octave_scalar&, octave_sparse_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_scalar&, const octave_sparse_complex_matrix&);
 
   SparseType typ = v2.sparse_type ();
   Matrix m1 = Matrix (1, 1, v1.scalar_value ());
--- a/src/OPERATORS/op-s-sm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-s-sm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -44,7 +44,7 @@
 
 DEFBINOP (div, scalar, sparse_matrix)
 {
-  CAST_BINOP_ARGS (const octave_scalar&, octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_scalar&, const octave_sparse_matrix&);
 
   SparseType typ = v2.sparse_type ();
   Matrix m1 = Matrix (1, 1, v1.double_value ());
--- a/src/OPERATORS/op-scm-cm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-scm-cm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -61,7 +61,7 @@
 
 DEFBINOP (ldiv, sparse_complex_matrix, complex_matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex_matrix&);
   SparseType typ = v1.sparse_type ();
 
   ComplexMatrix ret = xleftdiv (v1.sparse_complex_matrix_value (), 
--- a/src/OPERATORS/op-scm-cs.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-scm-cs.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -72,7 +72,7 @@
 
 DEFBINOP (ldiv, sparse_complex_matrix, complex)
 {
-  CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_complex&);
+  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex&);
 
   SparseType typ = v1.sparse_type ();
   SparseComplexMatrix m1 = v1.sparse_complex_matrix_value ();
--- a/src/OPERATORS/op-scm-m.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-scm-m.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -62,7 +62,7 @@
 
 DEFBINOP (ldiv, sparse_complex_matrix, matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_matrix&);
   
   SparseType typ = v1.sparse_type ();
 
--- a/src/OPERATORS/op-scm-s.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-scm-s.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -80,7 +80,7 @@
 
 DEFBINOP (ldiv, sparse_complex_matrix, scalar)
 {
-  CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_scalar&);
+  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_scalar&);
 
   SparseType typ = v1.sparse_type ();
   SparseComplexMatrix m1 = v1.sparse_complex_matrix_value ();
--- a/src/OPERATORS/op-scm-scm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-scm-scm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -96,7 +96,7 @@
 DEFBINOP (div, sparse_complex_matrix, sparse_complex_matrix)
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 
-		   octave_sparse_complex_matrix&);
+		   const octave_sparse_complex_matrix&);
   SparseType typ = v2.sparse_type ();
   SparseComplexMatrix ret = xdiv (v1.sparse_complex_matrix_value (), 
 				  v2.sparse_complex_matrix_value (), typ);
@@ -113,7 +113,7 @@
 
 DEFBINOP (ldiv, sparse_complex_matrix, sparse_complex_matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_complex_matrix&, 
+  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 
 		   const octave_sparse_complex_matrix&);
   SparseType typ = v1.sparse_type ();
 
--- a/src/OPERATORS/op-scm-sm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-scm-sm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -46,7 +46,7 @@
 
 DEFBINOP (div, sparse_complex_matrix, sparse_matrix)
 {
-  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_sparse_matrix&);
   SparseType typ = v2.sparse_type ();
   SparseComplexMatrix ret = xdiv (v1.sparse_complex_matrix_value (), 
 				  v2.sparse_matrix_value (), typ);
@@ -63,7 +63,7 @@
 
 DEFBINOP (ldiv, sparse_complex_matrix, sparse_matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_sparse_matrix&);
   SparseType typ = v1.sparse_type ();
 
   SparseComplexMatrix ret = xleftdiv (v1.sparse_complex_matrix_value (), 
--- a/src/OPERATORS/op-sm-cm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-sm-cm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -61,7 +61,7 @@
 
 DEFBINOP (ldiv, sparse_matrix, complex_matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_matrix&, const octave_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex_matrix&);
   SparseType typ = v1.sparse_type ();
 
   ComplexMatrix ret = xleftdiv (v1.sparse_matrix_value (), 
--- a/src/OPERATORS/op-sm-cs.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-sm-cs.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -72,7 +72,7 @@
 
 DEFBINOP (ldiv, sparse_matrix, complex)
 {
-  CAST_BINOP_ARGS (octave_sparse_matrix&, const octave_complex&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex&);
 
   SparseType typ = v1.sparse_type ();
   SparseMatrix m1 = v1.sparse_matrix_value ();
--- a/src/OPERATORS/op-sm-m.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-sm-m.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -60,7 +60,7 @@
 
 DEFBINOP (ldiv, sparse_matrix, matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_matrix&, const octave_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_matrix&);
   SparseType typ = v1.sparse_type ();
 
   Matrix ret = xleftdiv (v1.sparse_matrix_value (), 
--- a/src/OPERATORS/op-sm-s.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-sm-s.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -74,7 +74,7 @@
 
 DEFBINOP (ldiv, sparse_matrix, scalar)
 {
-  CAST_BINOP_ARGS (octave_sparse_matrix&, const octave_scalar&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_scalar&);
 
   SparseType typ = v1.sparse_type ();
   SparseMatrix m1 = v1.sparse_matrix_value ();
--- a/src/OPERATORS/op-sm-scm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-sm-scm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -46,7 +46,7 @@
 
 DEFBINOP (div, sparse_matrix, sparse_complex_matrix)
 {
-  CAST_BINOP_ARGS (const octave_sparse_matrix&, octave_sparse_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_complex_matrix&);
   SparseType typ = v2.sparse_type ();
   SparseComplexMatrix ret = xdiv (v1.sparse_matrix_value (), 
 				  v2.sparse_complex_matrix_value (), typ);
@@ -63,7 +63,7 @@
 
 DEFBINOP (ldiv, sparse_matrix, sparse_complex_matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_matrix&, const octave_sparse_complex_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_complex_matrix&);
   SparseType typ = v1.sparse_type ();
 
   SparseComplexMatrix ret = xleftdiv (v1.sparse_matrix_value (), 
--- a/src/OPERATORS/op-sm-sm.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-sm-sm.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -56,7 +56,7 @@
 
 DEFBINOP (div, sparse_matrix, sparse_matrix)
 {
-  CAST_BINOP_ARGS (const octave_sparse_matrix&, octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_matrix&);
   SparseType typ = v2.sparse_type ();
   SparseMatrix ret = xdiv (v1.sparse_matrix_value (), 
 			   v2.sparse_matrix_value (), typ);
@@ -73,7 +73,7 @@
 
 DEFBINOP (ldiv, sparse_matrix, sparse_matrix)
 {
-  CAST_BINOP_ARGS (octave_sparse_matrix&, const octave_sparse_matrix&);
+  CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_matrix&);
   SparseType typ = v1.sparse_type ();
 
   SparseMatrix ret = xleftdiv (v1.sparse_matrix_value (), 
--- a/src/OPERATORS/op-streamoff.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/OPERATORS/op-streamoff.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -70,7 +70,7 @@
 #define STREAMOFF_COMP_OP(FN, OP, T1, T2) \
   DEFBINOP (FN, T1, T2) \
   { \
-    CAST_BINOP_ARGS (const octave_ ## T1&, octave_ ## T2&); \
+    CAST_BINOP_ARGS (const octave_ ## T1&, const octave_ ## T2&); \
  \
     streamoff_array cm1 = v1.streamoff_array_value (); \
     streamoff_array cm2 = v2.streamoff_array_value (); \
--- a/src/dynamic-ld.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/dynamic-ld.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -269,7 +269,7 @@
   if (function)
     {
       octave_dld_fcn_installer f
-	= X_CAST (octave_dld_fcn_installer, function);
+	= reinterpret_cast<octave_dld_fcn_installer> (function);
 
       retval = f (oct_file);
 
--- a/src/load-save.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/load-save.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -286,7 +286,7 @@
 {
   const int magic_len = 10;
   char magic[magic_len+1];
-  is.read (X_CAST (char *, magic), magic_len);
+  is.read (magic, magic_len);
   magic[magic_len] = '\0';
 
   if (strncmp (magic, "Octave-1-L", magic_len) == 0)
@@ -301,7 +301,7 @@
     }
 	
   char tmp = 0;
-  is.read (X_CAST (char *, &tmp), 1);
+  is.read (&tmp, 1);
 
   flt_fmt = mopt_digit_to_float_format (tmp);
 
@@ -324,7 +324,7 @@
   std::ifstream file (fname.c_str ());
   OCTAVE_LOCAL_BUFFER (unsigned char, magic, 2);
 
-  if (file.read (X_CAST (char *, magic), 2) && magic[0] == 0x1f && 
+  if (file.read (reinterpret_cast<char *> (magic), 2) && magic[0] == 0x1f && 
       magic[1] == 0x8b)
     retval = true;
 
@@ -1212,9 +1212,9 @@
 	oct_mach_info::float_format flt_fmt =
 	  oct_mach_info::native_float_format ();
 
-	char tmp = (char) float_format_to_mopt_digit (flt_fmt);
+	char tmp = static_cast<char> (float_format_to_mopt_digit (flt_fmt));
 
-	os.write (X_CAST (char *, &tmp), 1);
+	os.write (&tmp, 1);
       }
       break;
 
@@ -1232,7 +1232,7 @@
 	memset (headertext, ' ', 124);
 	// ISO 8601 format date
 	strftime (headertext, 124, "MATLAB 5.0 MAT-file, written by Octave "
-		 OCTAVE_VERSION ", %Y-%m-%d %T UTC", &bdt);
+		  OCTAVE_VERSION ", %Y-%m-%d %T UTC", &bdt);
 
 	// The first pair of bytes give the version of the MAT file
 	// format.  The second pair of bytes form a magic number which
@@ -1266,7 +1266,7 @@
 #ifdef HAVE_HDF5
 	    if (format == LS_HDF5)
 	      {
-		hdf5_ofstream& hs = (hdf5_ofstream&) os;
+		hdf5_ofstream& hs = dynamic_cast<hdf5_ofstream&> (os);
 		H5Gset_comment (hs.file_id, "/", comment_string.c_str ());
 	      }
 	    else
--- a/src/ls-hdf5.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ls-hdf5.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -266,7 +266,7 @@
 	  H5Tset_size (st_id, slen);
 
 	  if (H5Dread (data_id, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, 
-		       (void *) typ) < 0)
+		       typ) < 0)
 	    goto done;
 
 	  H5Tclose (st_id);
@@ -528,7 +528,7 @@
 
   doc.resize (0);
 
-  hdf5_ifstream& hs = (hdf5_ifstream&) is;
+  hdf5_ifstream& hs = dynamic_cast<hdf5_ifstream&> (is);
   hdf5_callback_data d;
 
   // Versions of HDF5 prior to 1.2.2 had a bug in H5Giterate where it
@@ -602,7 +602,7 @@
 	{
 	  unsigned char attr_val = 1;
 
-	  retval = H5Awrite (a_id, H5T_NATIVE_UCHAR, (void*) &attr_val);
+	  retval = H5Awrite (a_id, H5T_NATIVE_UCHAR, &attr_val);
 
 	  H5Aclose (a_id);
 	}
@@ -639,7 +639,7 @@
   if (!empty)
     return 0;
 
-  space_hid = H5Screate_simple (1, &sz, (hsize_t *) 0);
+  space_hid = H5Screate_simple (1, &sz, 0);
   if (space_hid < 0) return space_hid;
 
   data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_IDX, space_hid, 
@@ -651,7 +651,7 @@
     }
   
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) dims) >= 0;
+		     H5P_DEFAULT, dims) >= 0;
 
   H5Dclose (data_hid);
   H5Sclose (space_hid);
@@ -681,7 +681,7 @@
   OCTAVE_LOCAL_BUFFER (octave_idx_type, dims, hdims);
 
   retval = H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-		    H5P_DEFAULT, (void *) dims);
+		    H5P_DEFAULT, dims);
   if (retval >= 0)
     {
       d.resize (hdims);
@@ -761,13 +761,13 @@
     goto error_cleanup;
 
   dims[0] = 0;
-  space_id = H5Screate_simple (0 , dims, (hsize_t*) 0);
+  space_id = H5Screate_simple (0 , dims, 0);
   if (space_id < 0)
     goto error_cleanup;
 
   data_type_id = H5Dcreate (data_id, "type",  type_id, space_id, H5P_DEFAULT);
   if (data_type_id < 0 || H5Dwrite (data_type_id, type_id, H5S_ALL, H5S_ALL, 
-				    H5P_DEFAULT, (void*) t.c_str ()) < 0)
+				    H5P_DEFAULT, t.c_str ()) < 0)
     goto error_cleanup;
 
   // Now call the real function to save the variable
@@ -814,7 +814,7 @@
 		const std::string& name, const std::string& doc,
 		bool mark_as_global, bool save_as_floats)
 {
-  hdf5_ofstream& hs = (hdf5_ofstream&) os;
+  hdf5_ofstream& hs = dynamic_cast<hdf5_ofstream&> (os);
 
   return add_hdf5_data (hs.file_id, tc, name, doc,
 			mark_as_global, save_as_floats);
--- a/src/ls-mat4.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ls-mat4.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -121,20 +121,20 @@
   // being able to read another mopt value should not result in an
   // error.
 
-  is.read (X_CAST (char *, &mopt), 4);
+  is.read (reinterpret_cast<char *> (&mopt), 4);
   if (! is)
     return 1;
 
-  if (! is.read (X_CAST (char *, &nr), 4))
+  if (! is.read (reinterpret_cast<char *> (&nr), 4))
     goto data_read_error;
 
-  if (! is.read (X_CAST (char *, &nc), 4))
+  if (! is.read (reinterpret_cast<char *> (&nc), 4))
     goto data_read_error;
 
-  if (! is.read (X_CAST (char *, &imag), 4))
+  if (! is.read (reinterpret_cast<char *> (&imag), 4))
     goto data_read_error;
 
-  if (! is.read (X_CAST (char *, &len), 4))
+  if (! is.read (reinterpret_cast<char *> (&len), 4))
     goto data_read_error;
 
 // If mopt is nonzero and the byte order is swapped, mopt will be
@@ -323,7 +323,7 @@
   {
     OCTAVE_LOCAL_BUFFER (char, name, len+1);
     name[len] = '\0';
-    if (! is.read (X_CAST (char *, name), len))
+    if (! is.read (name, len))
       goto data_read_error;
     retval = name;
 
@@ -399,25 +399,25 @@
 
   mopt += 1000 * float_format_to_mopt_digit (flt_fmt);
 
-  os.write (X_CAST (char *, &mopt), 4);
+  os.write (reinterpret_cast<char *> (&mopt), 4);
   
   FOUR_BYTE_INT nr = tc.rows ();
-  os.write (X_CAST (char *, &nr), 4);
+  os.write (reinterpret_cast<char *> (&nr), 4);
 
   FOUR_BYTE_INT nc = tc.columns ();
-  os.write (X_CAST (char *, &nc), 4);
+  os.write (reinterpret_cast<char *> (&nc), 4);
 
   octave_idx_type len = nr * nc;
 
   FOUR_BYTE_INT imag = tc.is_complex_type () ? 1 : 0;
-  os.write (X_CAST (char *, &imag), 4);
+  os.write (reinterpret_cast<char *> (&imag), 4);
 
   // LEN includes the terminating character, and the file is also
   // supposed to include it.
 
   FOUR_BYTE_INT name_len = name.length () + 1;
 
-  os.write (X_CAST (char *, &name_len), 4);
+  os.write (reinterpret_cast<char *> (&name_len), 4);
   os << name << '\0';
 
   if (tc.is_string ())
@@ -439,7 +439,7 @@
 	  for (octave_idx_type j = 0; j < ncol; j++)
 	    buf[j*nrow+i] = static_cast<double> (*s++ & 0x00FF);
        	}
-      os.write ((char *)buf, nrow*ncol*sizeof(double));
+      os.write (reinterpret_cast<char *> (buf), nrow*ncol*sizeof(double));
       
       unwind_protect::run_frame ("save_mat_binary_data");
     }
@@ -452,31 +452,31 @@
       for (octave_idx_type i = 0; i < nel; i++)
 	{
 	  double x = base + i * inc;
-	  os.write (X_CAST (char *, &x), 8);
+	  os.write (reinterpret_cast<char *> (&x), 8);
 	}
     }
   else if (tc.is_real_scalar ())
     {
       double tmp = tc.double_value ();
-      os.write (X_CAST (char *, &tmp), 8);
+      os.write (reinterpret_cast<char *> (&tmp), 8);
     }
   else if (tc.is_real_matrix ())
     {
       Matrix m = tc.matrix_value ();
-      os.write (X_CAST (char *, m.data ()), 8 * len);
+      os.write (reinterpret_cast<const char *> (m.data ()), 8 * len);
     }
   else if (tc.is_complex_scalar ())
     {
       Complex tmp = tc.complex_value ();
-      os.write (X_CAST (char *, &tmp), 16);
+      os.write (reinterpret_cast<char *> (&tmp), 16);
     }
   else if (tc.is_complex_matrix ())
     {
       ComplexMatrix m_cmplx = tc.complex_matrix_value ();
       Matrix m = ::real (m_cmplx);
-      os.write (X_CAST (char *, m.data ()), 8 * len);
+      os.write (reinterpret_cast<const char *> (m.data ()), 8 * len);
       m = ::imag (m_cmplx);
-      os.write (X_CAST (char *, m.data ()), 8 * len);
+      os.write (reinterpret_cast<const char *> (m.data ()), 8 * len);
     }
   else
     gripe_wrong_type_arg ("save", tc, false);
--- a/src/ls-mat5.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ls-mat5.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -179,14 +179,12 @@
     { \
       if (len > 0) \
 	{ \
-	  volatile TYPE *ptr = X_CAST (volatile TYPE *, data); \
-	  stream.read (X_CAST (char *, ptr), size * len); \
+	  OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
+	  stream.read (reinterpret_cast<char *> (ptr), size * len); \
 	  if (swap) \
 	    swap_bytes< size > (ptr, len); \
-	  TYPE tmp = ptr[0]; \
-	  for (int i = len - 1; i > 0; i--) \
+	  for (int i = 0; i < len; i++) \
 	    data[i] = ptr[i]; \
-	  data[0] = tmp; \
 	} \
     } \
   while (0)
@@ -289,7 +287,7 @@
 	int n = re.length (); \
 	tmp_pos = is.tellg (); \
 	read_mat5_integer_data (is, re.fortran_vec (), n, swap,	\
-				(enum mat5_data_type) type); \
+				static_cast<enum mat5_data_type> (type)); \
   \
 	if (! is || error_state) \
 	  { \
@@ -313,7 +311,7 @@
   \
 	    n = im.length (); \
 	    read_mat5_binary_data (is, im.fortran_vec (), n, swap, \
-				   (enum mat5_data_type) type, flt_fmt); \
+				   static_cast<enum mat5_data_type> (type), flt_fmt); \
   \
 	    if (! is || error_state) \
 	      { \
@@ -342,7 +340,7 @@
   unsigned int upper;
   FOUR_BYTE_INT temp;
 
-  if (! is.read (X_CAST (char *, &temp), 4 ))
+  if (! is.read (reinterpret_cast<char *> (&temp), 4 ))
     goto data_read_error;
 
   if (swap)
@@ -358,7 +356,7 @@
     }
   else
     {
-      if (! is.read (X_CAST (char *, &temp), 4 ))
+      if (! is.read (reinterpret_cast<char *> (&temp), 4 ))
 	goto data_read_error;
       if (swap)
 	swap_bytes<4> (&temp);
@@ -438,8 +436,9 @@
       // This will fail with an error Z_MEM_ERROR
       uLongf destLen = 8;
       OCTAVE_LOCAL_BUFFER (unsigned int, tmp, 2);
-      if (uncompress (X_CAST (Bytef *, tmp), &destLen, 
-		      X_CAST (Bytef *, inbuf), element_length) !=  Z_MEM_ERROR)
+      if (uncompress (reinterpret_cast<Bytef *> (tmp), &destLen, 
+		      reinterpret_cast<Bytef *> (inbuf), element_length)
+	  !=  Z_MEM_ERROR)
 	{
 	  // Why should I have to initialize outbuf as I'll just overwrite!!
 	  if (swap)
@@ -448,10 +447,10 @@
 	  destLen = tmp[1] + 8;
 	  std::string outbuf (destLen, ' '); 
 
-	  int err = uncompress (X_CAST (Bytef *, outbuf.c_str ()), &destLen, 
-			    X_CAST ( Bytef *, inbuf), element_length);
-	  //if (uncompress (X_CAST (Bytef *, outbuf.c_str ()), &destLen, 
-	  //		  X_CAST ( Bytef *, inbuf), element_length) != Z_OK)
+	  // XXX FIXME XXX -- find a way to avoid casting away const here!
+
+	  int err = uncompress (reinterpret_cast<Bytef *> (const_cast<char *> (outbuf.c_str ())), &destLen, 
+				reinterpret_cast<Bytef *> (inbuf), element_length);
 
 	  if (err != Z_OK)
 	    error ("load: error uncompressing data element");
@@ -494,7 +493,7 @@
   imag = (flags & 0x0800) != 0;	// has an imaginary part?
   global = (flags & 0x0400) != 0; // global variable?
   logicalvar = (flags & 0x0200) != 0; // boolean ?
-  arrayclass = (arrayclasstype)(flags & 0xff);
+  arrayclass = static_cast<arrayclasstype> (flags & 0xff);
   read_int (is, swap, nzmax);	// max number of non-zero in sparse
   
   // dimensions array subelement
@@ -535,7 +534,7 @@
 
     if (len)
       {
-	if (! is.read (X_CAST (char *, name), len ))
+	if (! is.read (name, len ))
 	  goto data_read_error;
 	
 	is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len)));
@@ -623,7 +622,7 @@
 	tmp_pos = is.tellg ();
 
 	read_mat5_integer_data (is, ridx, nzmax, swap,
-				(enum mat5_data_type) type);
+				static_cast<enum mat5_data_type> (type));
 
 	if (! is || error_state)
 	  {
@@ -643,7 +642,7 @@
 	tmp_pos = is.tellg ();
 
 	read_mat5_integer_data (is, cidx, nc + 1, swap,
-				(enum mat5_data_type) type);
+				static_cast<enum mat5_data_type> (type));
 
 	if (! is || error_state)
 	  {
@@ -670,7 +669,7 @@
 
 	tmp_pos = is.tellg ();
 	read_mat5_binary_data (is, data, nnz, swap,
-			       (enum mat5_data_type) type, flt_fmt);
+			       static_cast<enum mat5_data_type> (type), flt_fmt);
 
 	if (! is || error_state)
 	  {
@@ -692,7 +691,7 @@
 	      }
 
 	    read_mat5_binary_data (is, im.fortran_vec (), nnz, swap,
-				   (enum mat5_data_type) type, flt_fmt);
+				   static_cast<enum mat5_data_type> (type), flt_fmt);
 
 	    if (! is || error_state)
 	      {
@@ -734,7 +733,7 @@
 	    goto data_read_error;
 	  }
 
-	if (! is.read (X_CAST (char *, &field_name_length), fn_len ))
+	if (! is.read (reinterpret_cast<char *> (&field_name_length), fn_len ))
 	  goto data_read_error;
 
 	if (swap)
@@ -858,7 +857,7 @@
 	int n = re.length ();
 	tmp_pos = is.tellg ();
 	read_mat5_binary_data (is, re.fortran_vec (), n, swap,
-			       (enum mat5_data_type) type, flt_fmt);
+			       static_cast<enum mat5_data_type> (type), flt_fmt);
 
 	if (! is || error_state)
 	  {
@@ -894,7 +893,7 @@
 
 	    n = im.length ();
 	    read_mat5_binary_data (is, im.fortran_vec (), n, swap,
-				   (enum mat5_data_type) type, flt_fmt);
+				   static_cast<enum mat5_data_type> (type), flt_fmt);
 
 	    if (! is || error_state)
 	      {
@@ -977,8 +976,8 @@
   TWO_BYTE_INT version=0, magic=0;
 
   is.seekg (124, std::ios::beg);
-  is.read (X_CAST (char *, &version), 2);
-  is.read (X_CAST (char *, &magic), 2);
+  is.read (reinterpret_cast<char *> (&version), 2);
+  is.read (reinterpret_cast<char *> (&magic), 2);
 
   if (magic == 0x4d49)
     swap = 0;
@@ -1011,12 +1010,12 @@
   else
     {
       temp = type;
-      if (! is.write ((char *)&temp, 4))
+      if (! is.write (reinterpret_cast<char *> (&temp), 4))
 	goto data_write_error;
       temp = bytes;
     }
 
-  if (! is.write ((char *)&temp, 4))
+  if (! is.write (reinterpret_cast<char *> (&temp), 4))
     goto data_write_error;
 
   return 0;
@@ -1041,14 +1040,14 @@
 // Have to use copy here to avoid writing over data accessed via
 // Matrix::data().
 
-#define MAT5_DO_WRITE(TYPE, data, count, stream)			\
-  do									\
-    {									\
-      OCTAVE_LOCAL_BUFFER (TYPE, ptr, count);                           \
-      for (int i = 0; i < count; i++)					\
-        ptr[i] = X_CAST (TYPE, data[i]);				\
-      stream.write (X_CAST (char *, ptr), count * sizeof (TYPE));	\
-    }									\
+#define MAT5_DO_WRITE(TYPE, data, count, stream) \
+  do \
+    { \
+      OCTAVE_LOCAL_BUFFER (TYPE, ptr, count); \
+      for (int i = 0; i < count; i++) \
+        ptr[i] = static_cast<TYPE> (data[i]); \
+      stream.write (reinterpret_cast<char *> (ptr), count * sizeof (TYPE)); \
+    } \
   while (0)
 
   if (save_as_floats)
@@ -1127,7 +1126,7 @@
 	break;
 
       case LS_DOUBLE: // No conversion necessary.
-	os.write (X_CAST (char *, data), len);
+	os.write (reinterpret_cast<const char *> (data), len);
 	break;
 
       default:
@@ -1186,7 +1185,7 @@
   len = nel*size;
   write_mat5_tag (os, mst, len);
 
-  os.write (X_CAST(char *, m), len);
+  os.write (reinterpret_cast<const char *> (m), len);
 
   if (PAD (len) > len)
     {
@@ -1485,10 +1484,10 @@
 	  uLongf destLen = srcLen * 101 / 100 + 12; 
 	  OCTAVE_LOCAL_BUFFER (char, out_buf, destLen);
 
-	  if (compress (X_CAST (Bytef *, out_buf), &destLen, 
-			X_CAST (Bytef *, OSSTREAM_C_STR (buf)), srcLen) == Z_OK)
+	  if (compress (reinterpret_cast<Bytef *> (out_buf), &destLen, 
+			reinterpret_cast<const Bytef *> (OSSTREAM_C_STR (buf)), srcLen) == Z_OK)
 	    {
-	      write_mat5_tag (os, miCOMPRESSED, X_CAST(int, destLen)); 
+	      write_mat5_tag (os, miCOMPRESSED, static_cast<int> (destLen)); 
 	      os.write (out_buf, destLen);
 	    }
 	  else
@@ -1569,8 +1568,8 @@
       goto error_cleanup;
     }
 
-  os.write ((char *)&flags, 4);
-  os.write ((char *)&nnz, 4);
+  os.write (reinterpret_cast<char *> (&flags), 4);
+  os.write (reinterpret_cast<char *> (&nnz), 4);
 
   {
     dim_vector dv = tc.dims ();
@@ -1582,7 +1581,7 @@
     for (int i = 0; i < nd; i++)
       {
 	FOUR_BYTE_INT n = dv(i);
-	os.write ((char *)&n, 4);
+	os.write (reinterpret_cast<char *> (&n), 4);
       }
 
     if (PAD (dim_len) > dim_len)
@@ -1628,10 +1627,10 @@
 	  for (int j = 0; j < nc; j++)
 	    buf[j*nr+i] = *s++ & 0x00FF;
 	}
-      os.write ((char *)buf, nr*nc*2);
+      os.write (reinterpret_cast<char *> (buf), nr*nc*2);
       
       if (paddedlength > len)
-	os.write ((char *)buf, paddedlength - len);
+	os.write (reinterpret_cast<char *> (buf), paddedlength - len);
     }
   else if (cname == "sparse")
     {
@@ -1762,7 +1761,7 @@
 	  fieldcnt++;
 
 	write_mat5_tag (os, miINT32, 4);
-	os.write ((char *)&maxfieldnamelength, 4);
+	os.write (reinterpret_cast<char *> (&maxfieldnamelength), 4);
 	write_mat5_tag (os, miINT8, fieldcnt*maxfieldnamelength);
 
 	for (Octave_map::const_iterator i = m.begin (); i != m.end (); i++)
--- a/src/ls-oct-binary.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ls-oct-binary.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -150,7 +150,7 @@
   // We expect to fail here, at the beginning of a record, so not
   // being able to read another name should not result in an error.
 
-  is.read (X_CAST (char *, &name_len), 4);
+  is.read (reinterpret_cast<char *> (&name_len), 4);
   if (! is)
     return retval;
   if (swap)
@@ -159,12 +159,12 @@
   {
     OCTAVE_LOCAL_BUFFER (char, name, name_len+1);
     name[name_len] = '\0';
-    if (! is.read (X_CAST (char *, name), name_len))
+    if (! is.read (reinterpret_cast<char *> (name), name_len))
       goto data_read_error;
     retval = name;
   }
 
-  is.read (X_CAST (char *, &doc_len), 4);
+  is.read (reinterpret_cast<char *> (&doc_len), 4);
   if (! is)
     goto data_read_error;
   if (swap)
@@ -173,17 +173,17 @@
   {
     OCTAVE_LOCAL_BUFFER (char, tdoc, doc_len+1);
     tdoc[doc_len] = '\0';
-    if (! is.read (X_CAST (char *, tdoc), doc_len))
+    if (! is.read (reinterpret_cast<char *> (tdoc), doc_len))
       goto data_read_error;
     doc = tdoc;
   }
 
-  if (! is.read (X_CAST (char *, &tmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
     goto data_read_error;
   global = tmp ? 1 : 0;
 
   tmp = 0;
-  if (! is.read (X_CAST (char *, &tmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
     goto data_read_error;
 
   // All cases except 255 kept for backwards compatibility
@@ -211,12 +211,12 @@
 	// This is cruft, since its for a save type that is old. Maybe
 	// this is taking backward compatability too far!!
 	FOUR_BYTE_INT len;
-	if (! is.read (X_CAST (char *, &len), 4))
+	if (! is.read (reinterpret_cast<char *> (&len), 4))
 	  goto data_read_error;
 	if (swap)
 	  swap_bytes<4> (&len);
 	OCTAVE_LOCAL_BUFFER (char, s, len+1);
-	if (! is.read (X_CAST (char *, s), len))
+	if (! is.read (reinterpret_cast<char *> (s), len))
 	  goto data_read_error;
 	s[len] = '\0';
 	tc = s;
@@ -238,12 +238,12 @@
       {
 	// Read the saved variable type
 	FOUR_BYTE_INT len;
-	if (! is.read (X_CAST (char *, &len), 4))
+	if (! is.read (reinterpret_cast<char *> (&len), 4))
 	  goto data_read_error;
 	if (swap)
 	  swap_bytes<4> (&len);
 	OCTAVE_LOCAL_BUFFER (char, s, len+1);
-	if (! is.read (X_CAST (char *, s), len))
+	if (! is.read (s, len))
 	  goto data_read_error;
 	s[len] = '\0';
 	std::string typ = s;
@@ -275,29 +275,29 @@
 {
   FOUR_BYTE_INT name_len = name.length ();
 
-  os.write (X_CAST (char *, &name_len), 4);
+  os.write (reinterpret_cast<char *> (&name_len), 4);
   os << name;
 
   FOUR_BYTE_INT doc_len = doc.length ();
 
-  os.write (X_CAST (char *, &doc_len), 4);
+  os.write (reinterpret_cast<char *> (&doc_len), 4);
   os << doc;
 
   unsigned char tmp;
 
   tmp = mark_as_global;
-  os.write (X_CAST (char *, &tmp), 1);
+  os.write (reinterpret_cast<char *> (&tmp), 1);
 
   // 255 flags the new binary format
   tmp = 255;
-  os.write (X_CAST (char *, &tmp), 1);
+  os.write (reinterpret_cast<char *> (&tmp), 1);
 
   // Write the string corresponding to the octave_value type
   std::string typ = tc.type_name ();
   FOUR_BYTE_INT len = typ.length ();
-  os.write (X_CAST (char *, &len), 4);
+  os.write (reinterpret_cast<char *> (&len), 4);
   const char *btmp = typ.data ();
-  os.write (X_CAST (char *, btmp), len);
+  os.write (btmp, len);
       
   // The octave_value of tc is const. Make a copy...
   octave_value val = tc;
--- a/src/mappers.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/mappers.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -121,7 +121,7 @@
 static int
 xtoascii (int c)
 {
-  return toascii ((int) ((unsigned char) c));
+  return toascii (c);
 }
 
 static int
--- a/src/oct-procbuf.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/oct-procbuf.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -241,7 +241,7 @@
       && ! xisnan (val))
     {
       int ival = NINT (val);
-      if (ival >= 0 && (double) ival == val)
+      if (ival >= 0 && static_cast<double> (ival) == val)
 	{
 	  Vkluge_procbuf_delay = ival;
 	  return 0;
--- a/src/oct-stream.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/oct-stream.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -288,7 +288,7 @@
       unsigned char c = s[i++];
 
       if (c == '-' && i > 1 && i < len
-	  && (unsigned char) s[i-2] <= (unsigned char) s[i])
+	  && static_cast<unsigned char> (s[i-2]) <= static_cast<unsigned char> (s[i]))
 	{
 	  // Add all characters from the range except the first (we
 	  // already added it below).
@@ -990,14 +990,14 @@
 	  if (c == '\n')
 	    {
 	      if (! strip_newline)
-		buf << (char) c;
+		buf << static_cast<char> (c);
 	      else
 		newline_stripped = 1;
 
 	      break;
 	    }
 	  else
-	    buf << (char) c;
+	    buf << static_cast<char> (c);
 
 	  if (max_len > 0 && char_count == max_len)
 	    break;
@@ -1454,7 +1454,7 @@
   int n = 0; \
  \
   while (is && n < width && (c = is.get ()) != EOF) \
-    tbuf[n++] = (char) c; \
+    tbuf[n++] = static_cast<char> (c);		    \
  \
   tbuf[n] = '\0'; \
  \
@@ -1548,13 +1548,13 @@
 	    { \
 	      while (is && (c = is.get ()) != EOF \
 		     && char_class.find (c) != NPOS) \
-		buf << (char) c; \
+		buf << static_cast<char> (c);	     \
 	    } \
 	  else \
 	    { \
 	      while (is && (c = is.get ()) != EOF \
 		     && char_class.find (c) == NPOS) \
-		buf << (char) c; \
+		buf << static_cast<char> (c);		     \
 	    } \
  \
 	  if (c != EOF) \
--- a/src/ops.h	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ops.h	Fri Apr 14 04:01:40 2006 +0000
@@ -137,14 +137,14 @@
   while (0)
 
 #define CAST_UNOP_ARG(t) \
-  t v = DYNAMIC_CAST (t, a)
+  t v = dynamic_cast<t> (a)
 
 #define CAST_BINOP_ARGS(t1, t2) \
-  t1 v1 = DYNAMIC_CAST (t1, a1); \
-  t2 v2 = DYNAMIC_CAST (t2, a2)
+  t1 v1 = dynamic_cast<t1> (a1);		\
+  t2 v2 = dynamic_cast<t2> (a2)
 
 #define CAST_CONV_ARG(t) \
-  t v = DYNAMIC_CAST (t, a)
+  t v = dynamic_cast<t> (a)
 
 #define ASSIGNOPDECL(name) \
   static octave_value \
@@ -182,7 +182,7 @@
 #define DEFASSIGNANYOP_FN(name, t1, f) \
   ASSIGNANYOPDECL (name) \
   { \
-    octave_ ## t1& v1 = DYNAMIC_CAST (octave_ ## t1&, a1); \
+    octave_ ## t1& v1 = dynamic_cast<octave_ ## t1&> (a1); \
  \
     v1.f (idx, a2); \
     return octave_value (); \
--- a/src/ov-base-int.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-base-int.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -135,14 +135,14 @@
 
   // Use negative value for ndims to differentiate with old format!!
   FOUR_BYTE_INT tmp = - d.length();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i=0; i < d.length (); i++)
     {
       tmp = d(i);
-      os.write (X_CAST (char *, &tmp), 4);
+      os.write (reinterpret_cast<char *> (&tmp), 4);
     }
 
-  os.write (X_CAST(char *, this->matrix.data()), this->byte_size());
+  os.write (reinterpret_cast<const char *> (this->matrix.data()), this->byte_size());
 
   return true;
 }
@@ -153,7 +153,7 @@
 					oct_mach_info::float_format )
 {
   FOUR_BYTE_INT mdims;
-  if (! is.read (X_CAST (char *, &mdims), 4))
+  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
     return false;
   if (swap)
     swap_bytes<4> (&mdims);
@@ -167,7 +167,7 @@
 
   for (int i = 0; i < mdims; i++)
     {
-      if (! is.read (X_CAST (char *, &di), 4))
+      if (! is.read (reinterpret_cast<char *> (&di), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&di);
@@ -188,7 +188,7 @@
 
   T m (dv);
 
-  if (! is.read (X_CAST (char *, m.data ()), m.byte_size ()))
+  if (! is.read (reinterpret_cast<char *> (m.fortran_vec ()), m.byte_size ()))
     return false;
 
   if (swap)
@@ -354,7 +354,7 @@
 bool 
 octave_base_int_scalar<T>::save_binary (std::ostream& os, bool&)
 {
-  os.write (X_CAST(char *, &(this->scalar)), this->byte_size());
+  os.write (reinterpret_cast<char *> (&(this->scalar)), this->byte_size());
   return true;
 }
 
@@ -364,7 +364,7 @@
 					oct_mach_info::float_format)
 {
   T tmp;
-  if (! is.read (X_CAST (char *, &tmp), this->byte_size()))
+  if (! is.read (reinterpret_cast<char *> (&tmp), this->byte_size()))
     return false;
 
   if (swap)
--- a/src/ov-base-sparse.h	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-base-sparse.h	Fri Apr 14 04:01:40 2006 +0000
@@ -118,7 +118,7 @@
   octave_value any (int dim = 0) const { return matrix.any (dim); }
 
   SparseType sparse_type (void) const { return typ; }
-  SparseType sparse_type (const SparseType& _typ) 
+  SparseType sparse_type (const SparseType& _typ) const
     { SparseType ret = typ; typ = _typ; return ret; }
 
   bool is_matrix_type (void) const { return true; }
@@ -152,7 +152,7 @@
 
   T matrix;
 
-  SparseType typ;
+  mutable SparseType typ;
 };
 
 #endif
--- a/src/ov-bool-mat.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-bool-mat.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -287,11 +287,11 @@
 
   // Use negative value for ndims to differentiate with old format!!
   FOUR_BYTE_INT tmp = - d.length();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
       tmp = d(i);
-      os.write (X_CAST (char *, &tmp), 4);
+      os.write (reinterpret_cast<char *> (&tmp), 4);
     }
 
   boolNDArray m = bool_array_value ();
@@ -312,7 +312,7 @@
 				 oct_mach_info::float_format /* fmt */)
 {
   FOUR_BYTE_INT mdims;
-  if (! is.read (X_CAST (char *, &mdims), 4))
+  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
     return false;
   if (swap)
     swap_bytes<4> (&mdims);
@@ -329,7 +329,7 @@
 
   for (int i = 0; i < mdims; i++)
     {
-      if (! is.read (X_CAST (char *, &di), 4))
+      if (! is.read (reinterpret_cast<char *> (&di), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&di);
--- a/src/ov-bool-sparse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-bool-sparse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -210,16 +210,16 @@
   FOUR_BYTE_INT itmp;
   // Use negative value for ndims to be consistent with other formats
   itmp= -2;        
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nr;    
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nc;
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nz;
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
 
   // add one to the printed indices to go from
   // zero-based to one-based arrays
@@ -227,14 +227,14 @@
     {
       OCTAVE_QUIT;
       itmp = matrix.cidx(i);
-      os.write (X_CAST (char *, &itmp), 4);
+      os.write (reinterpret_cast<char *> (&itmp), 4);
     }
 
   for (int i = 0; i < nz; i++) 
     {
       OCTAVE_QUIT;
       itmp = matrix.ridx(i); 
-      os.write (X_CAST (char *, &itmp), 4);
+      os.write (reinterpret_cast<char *> (&itmp), 4);
     }
 
   OCTAVE_LOCAL_BUFFER (char, htmp, nz);
@@ -252,7 +252,7 @@
 					oct_mach_info::float_format /* fmt */)
 {
   FOUR_BYTE_INT nz, nc, nr, tmp;
-  if (! is.read (X_CAST (char *, &tmp), 4))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
     return false;
 
   if (swap)
@@ -263,11 +263,11 @@
     return false;
   }
 
-  if (! is.read (X_CAST (char *, &nr), 4))
+  if (! is.read (reinterpret_cast<char *> (&nr), 4))
     return false;
-  if (! is.read (X_CAST (char *, &nc), 4))
+  if (! is.read (reinterpret_cast<char *> (&nc), 4))
     return false;
-  if (! is.read (X_CAST (char *, &nz), 4))
+  if (! is.read (reinterpret_cast<char *> (&nz), 4))
     return false;
 
   if (swap)
@@ -284,7 +284,7 @@
   for (int i = 0; i < nc+1; i++) 
     {
       OCTAVE_QUIT;
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
@@ -294,7 +294,7 @@
   for (int i = 0; i < nz; i++) 
     {
       OCTAVE_QUIT;
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
@@ -339,14 +339,14 @@
   octave_idx_type tmp;
   hsize_t hdims[2];
 
-  space_hid = H5Screate_simple (0, hdims, (hsize_t*) 0);
+  space_hid = H5Screate_simple (0, hdims, 0);
   if (space_hid < 0) 
     {
       H5Gclose (group_hid);
       return false;
     }
 
-  data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, space_hid, 
+  data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, space_hid,
 			H5P_DEFAULT);
   if (data_hid < 0) 
     {
@@ -356,8 +356,7 @@
     }
   
   tmp = m.rows ();
-  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-		     H5P_DEFAULT, (void*) &tmp) >= 0;
+  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -366,7 +365,7 @@
       return false;
     }    
 
-  data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, space_hid, 
+  data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, space_hid,
 			H5P_DEFAULT);
   if (data_hid < 0) 
     {
@@ -377,7 +376,7 @@
   
   tmp = m.cols ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) &tmp) >= 0;
+		     H5P_DEFAULT, &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -397,7 +396,7 @@
   
   tmp = m.nzmax ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) &tmp) >= 0;
+		     H5P_DEFAULT, &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -430,7 +429,7 @@
   
   octave_idx_type * itmp = m.xcidx ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) itmp) >= 0;
+		     H5P_DEFAULT, itmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -463,7 +462,7 @@
   
   itmp = m.xridx ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) itmp) >= 0;
+		     H5P_DEFAULT, itmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -486,7 +485,7 @@
     htmp[i] = m.xdata(i);
 
   retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) htmp) >= 0;
+		     H5P_DEFAULT, htmp) >= 0;
   H5Dclose (data_hid);
   H5Sclose (space_hid);
   H5Gclose (group_hid);
@@ -523,8 +522,7 @@
       return false;
     }
 
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nr) < 0)
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nr) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -544,8 +542,7 @@
       return false;
     }
 
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nc) < 0)
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nc) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -565,8 +562,7 @@
       return false;
     }
 
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nz) < 0)
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nz) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -606,8 +602,7 @@
     }
 
   octave_idx_type *itmp = m.xcidx ();
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) itmp) < 0) 
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, itmp) < 0) 
     {
       H5Sclose (space_hid);
       H5Dclose (data_hid);
@@ -642,8 +637,7 @@
     }
 
   itmp = m.xridx ();
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) itmp) < 0) 
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, itmp) < 0) 
     {
       H5Sclose (space_hid);
       H5Dclose (data_hid);
@@ -679,8 +673,7 @@
 
   hbool_t htmp[nz];
   bool retval = false;
-  if (H5Dread (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) htmp) >= 0) 
+  if (H5Dread (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT, htmp) >= 0) 
     {
       retval = true;
 
--- a/src/ov-bool.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-bool.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -162,7 +162,7 @@
 octave_bool::save_binary (std::ostream& os, bool& /* save_as_floats */)
 {
   char tmp = (scalar ? 1 : 0);
-  os.write (X_CAST (char *, &tmp), 1);
+  os.write (reinterpret_cast<char *> (&tmp), 1);
 
   return true;
 }
@@ -172,7 +172,7 @@
 			  oct_mach_info::float_format /* fmt */)
 {
   char tmp;
-  if (! is.read (X_CAST (char *, &tmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
     return false;
   scalar = (tmp ? 1 : 0);
   return true;
--- a/src/ov-cell.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-cell.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -623,11 +623,11 @@
 
   // Use negative value for ndims
   FOUR_BYTE_INT di = - d.length();
-  os.write (X_CAST (char *, &di), 4);
+  os.write (reinterpret_cast<char *> (&di), 4);
   for (int i = 0; i < d.length (); i++)
     {
       di = d(i);
-      os.write (X_CAST (char *, &di), 4);
+      os.write (reinterpret_cast<char *> (&di), 4);
     }
   
   Cell tmp = cell_value ();
@@ -653,7 +653,7 @@
 {
   bool success = true;
   FOUR_BYTE_INT mdims;
-  if (! is.read (X_CAST (char *, &mdims), 4))
+  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
     return false;
   if (swap)
     swap_bytes<4> (&mdims);
@@ -667,7 +667,7 @@
 
   for (int i = 0; i < mdims; i++)
     {
-      if (! is.read (X_CAST (char *, &di), 4))
+      if (! is.read (reinterpret_cast<char *> (&di), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&di);
--- a/src/ov-complex.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-complex.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -232,10 +232,10 @@
 bool 
 octave_complex::save_binary (std::ostream& os, bool& /* save_as_floats */)
 {
-  char tmp = (char) LS_DOUBLE;
-  os.write (X_CAST (char *, &tmp), 1);
+  char tmp = static_cast<char> (LS_DOUBLE);
+  os.write (reinterpret_cast<char *> (&tmp), 1);
   Complex ctmp = complex_value ();
-  os.write (X_CAST (char *, &ctmp), 16);
+  os.write (reinterpret_cast<char *> (&ctmp), 16);
 
   return true;
 }
@@ -245,12 +245,12 @@
 			     oct_mach_info::float_format fmt)
 {
   char tmp;
-  if (! is.read (X_CAST (char *, &tmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
     return false;
 
   Complex ctmp;
-  read_doubles (is, X_CAST (double *, &ctmp), X_CAST (save_type, tmp), 2, 
-		swap, fmt);
+  read_doubles (is, reinterpret_cast<double *> (&ctmp),
+		static_cast<save_type> (tmp), 2, swap, fmt);
   if (error_state || ! is)
     return false;
 
--- a/src/ov-cx-mat.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-cx-mat.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -384,11 +384,11 @@
 
   // Use negative value for ndims to differentiate with old format!!
   FOUR_BYTE_INT tmp = - d.length();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
       tmp = d(i);
-      os.write (X_CAST (char *, &tmp), 4);
+      os.write (reinterpret_cast<char *> (&tmp), 4);
     }
 
   ComplexNDArray m = complex_array_value ();
@@ -412,7 +412,7 @@
 
 
   const Complex *mtmp = m.data ();
-  write_doubles (os, X_CAST (const double *, mtmp), st, 2 * d.numel ());
+  write_doubles (os, reinterpret_cast<const double *> (mtmp), st, 2 * d.numel ());
 
   return true;
 }
@@ -423,7 +423,7 @@
 {
   char tmp;
   FOUR_BYTE_INT mdims;
-  if (! is.read (X_CAST (char *, &mdims), 4))
+  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
     return false;
   if (swap)
     swap_bytes<4> (&mdims);
@@ -436,7 +436,7 @@
 
       for (int i = 0; i < mdims; i++)
 	{
-	  if (! is.read (X_CAST (char *, &di), 4))
+	  if (! is.read (reinterpret_cast<char *> (&di), 4))
 	    return false;
 	  if (swap)
 	    swap_bytes<4> (&di);
@@ -455,13 +455,13 @@
 	  dv(0) = 1;
 	}
 
-      if (! is.read (X_CAST (char *, &tmp), 1))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 1))
 	return false;
 
       ComplexNDArray m(dv);
       Complex *im = m.fortran_vec ();
-      read_doubles (is, X_CAST (double *, im), X_CAST (save_type, tmp), 
-		    2 * dv.numel (), swap, fmt);
+      read_doubles (is, reinterpret_cast<double *> (im),
+		    static_cast<save_type> (tmp), 2 * dv.numel (), swap, fmt);
       if (error_state || ! is)
 	return false;
       matrix = m;
@@ -470,17 +470,17 @@
     {
       FOUR_BYTE_INT nr, nc;
       nr = mdims;
-      if (! is.read (X_CAST (char *, &nc), 4))
+      if (! is.read (reinterpret_cast<char *> (&nc), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&nc);
-      if (! is.read (X_CAST (char *, &tmp), 1))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 1))
 	return false;
       ComplexMatrix m (nr, nc);
       Complex *im = m.fortran_vec ();
       octave_idx_type len = nr * nc;
-      read_doubles (is, X_CAST (double *, im),
-		    X_CAST (save_type, tmp), 2*len, swap, fmt);
+      read_doubles (is, reinterpret_cast<double *> (im),
+		    static_cast<save_type> (tmp), 2*len, swap, fmt);
       if (error_state || ! is)
 	return false;
       matrix = m;
--- a/src/ov-cx-sparse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-cx-sparse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -216,16 +216,16 @@
   FOUR_BYTE_INT itmp;
   // Use negative value for ndims to be consistent with other formats
   itmp= -2;        
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nr;    
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nc;
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nz;
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
 
   save_type st = LS_DOUBLE;
   if (save_as_floats)
@@ -251,17 +251,17 @@
      {
        OCTAVE_QUIT;
        itmp = matrix.cidx(i);
-       os.write (X_CAST (char *, &itmp), 4);
+       os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
    for (int i = 0; i < nz; i++) 
      {
        OCTAVE_QUIT;
        itmp = matrix.ridx(i); 
-       os.write (X_CAST (char *, &itmp), 4);
+       os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
-   write_doubles (os, X_CAST (const double *, matrix.data()), st, 2 * nz);
+   write_doubles (os, reinterpret_cast<const double *> (matrix.data()), st, 2 * nz);
 
   return true;
 }
@@ -273,7 +273,7 @@
   FOUR_BYTE_INT nz, nc, nr, tmp;
   char ctmp;
 
-  if (! is.read (X_CAST (char *, &tmp), 4))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
     return false;
 
   if (swap)
@@ -284,11 +284,11 @@
     return false;
   }
 
-  if (! is.read (X_CAST (char *, &nr), 4))
+  if (! is.read (reinterpret_cast<char *> (&nr), 4))
     return false;
-  if (! is.read (X_CAST (char *, &nc), 4))
+  if (! is.read (reinterpret_cast<char *> (&nc), 4))
     return false;
-  if (! is.read (X_CAST (char *, &nz), 4))
+  if (! is.read (reinterpret_cast<char *> (&nz), 4))
     return false;
 
   if (swap)
@@ -305,7 +305,7 @@
   for (int i = 0; i < nc+1; i++) 
     {
       OCTAVE_QUIT;
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
@@ -315,18 +315,18 @@
   for (int i = 0; i < nz; i++) 
     {
       OCTAVE_QUIT;
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
       m.ridx(i) = tmp;
     }
 
-  if (! is.read (X_CAST (char *, &ctmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&ctmp), 1))
     return false;
   
-  read_doubles (is, X_CAST(double *, m.data()), X_CAST (save_type, ctmp), 
-		2 * nz, swap, fmt);
+  read_doubles (is, reinterpret_cast<double *> (m.data ()),
+		static_cast<save_type> (ctmp), 2 * nz, swap, fmt);
 
   if (error_state || ! is)
     return false;
@@ -358,7 +358,7 @@
   octave_idx_type tmp;
   hsize_t hdims[2];
 
-  space_hid = H5Screate_simple (0, hdims, (hsize_t*) 0);
+  space_hid = H5Screate_simple (0, hdims, 0);
   if (space_hid < 0) 
     {
       H5Gclose (group_hid);
@@ -376,7 +376,7 @@
   
   tmp = m.rows ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) &tmp) >= 0;
+		     H5P_DEFAULT, &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -396,7 +396,7 @@
   
   tmp = m.cols ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) &tmp) >= 0;
+		     H5P_DEFAULT, &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -416,7 +416,7 @@
   
   tmp = m.nzmax ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) &tmp) >= 0;
+		     H5P_DEFAULT, &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -449,7 +449,7 @@
   
   octave_idx_type * itmp = m.xcidx ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) itmp) >= 0;
+		     H5P_DEFAULT, itmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -481,8 +481,7 @@
     }
   
   itmp = m.xridx ();
-  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) itmp) >= 0;
+  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, itmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -523,8 +522,7 @@
       return false;
     }
 
-  data_hid = H5Dcreate (group_hid, "data", type_hid, space_hid, 
-			H5P_DEFAULT);
+  data_hid = H5Dcreate (group_hid, "data", type_hid, space_hid, H5P_DEFAULT);
   if (data_hid < 0)
     {
       H5Sclose (space_hid);
@@ -540,7 +538,7 @@
       Complex * ctmp = m.xdata ();
 
       retval = H5Dwrite (data_hid, complex_type_hid, H5S_ALL, H5S_ALL,
-			 H5P_DEFAULT, (void*) ctmp) >= 0;
+			 H5P_DEFAULT, ctmp) >= 0;
     }
 
   H5Dclose (data_hid);
@@ -580,8 +578,7 @@
       return false;
     }
 
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nr) < 0)
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nr) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -601,8 +598,7 @@
       return false;
     }
 
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nc) < 0)
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nc) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -622,8 +618,7 @@
       return false;
     }
 
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nz) < 0)
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nz) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -663,8 +658,7 @@
     }
 
   octave_idx_type *itmp = m.xcidx ();
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) itmp) < 0) 
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, itmp) < 0) 
     {
       H5Sclose (space_hid);
       H5Dclose (data_hid);
@@ -699,8 +693,7 @@
     }
 
   itmp = m.xridx ();
-  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) itmp) < 0) 
+  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT, itmp) < 0) 
     {
       H5Sclose (space_hid);
       H5Dclose (data_hid);
@@ -748,8 +741,7 @@
 
   Complex *ctmp = m.xdata ();
   bool retval = false;
-  if (H5Dread (data_hid, complex_type, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-	       (void *) ctmp) >= 0) 
+  if (H5Dread (data_hid, complex_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, ctmp) >= 0) 
     {
       retval = true;
       matrix = m;
--- a/src/ov-fcn-handle.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-fcn-handle.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -218,7 +218,7 @@
 octave_fcn_handle::save_binary (std::ostream& os, bool&)
 {
   FOUR_BYTE_INT tmp = nm.length ();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   os.write (nm.c_str (), nm.length ());
   if (nm == "@<anonymous>")
     {
@@ -227,7 +227,7 @@
       std::string stmp = OSSTREAM_STR (buf);
       OSSTREAM_FREEZE (buf);
       tmp = stmp.length ();
-      os.write (X_CAST (char *, &tmp), 4);
+      os.write (reinterpret_cast<char *> (&tmp), 4);
       os.write (stmp.c_str (), stmp.length ());
     }
   return true;
@@ -238,7 +238,7 @@
 				oct_mach_info::float_format)
 {
   FOUR_BYTE_INT tmp;
-  if (! is.read (X_CAST (char *, &tmp), 4))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
     return false;
   if (swap)
     swap_bytes<4> (&tmp);
@@ -252,7 +252,7 @@
 
   if (nm == "@<anonymous>")
     {
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
@@ -307,7 +307,7 @@
   OCTAVE_LOCAL_BUFFER (hsize_t, hdims, 2);
   hdims[0] = 0;
   hdims[1] = 0;
-  space_hid = H5Screate_simple (0 , hdims, (hsize_t*) 0);
+  space_hid = H5Screate_simple (0 , hdims, 0);
   if (space_hid < 0)
     {
       H5Tclose (type_hid);
@@ -317,8 +317,7 @@
 
   data_hid = H5Dcreate (group_hid, "nm",  type_hid, space_hid, H5P_DEFAULT);
   if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL,
-				H5P_DEFAULT,
-				X_CAST (void *, nm.c_str ())) < 0)
+				H5P_DEFAULT, nm.c_str ()) < 0)
     {
       H5Sclose (space_hid);
       H5Tclose (type_hid);
@@ -345,8 +344,7 @@
       data_hid = H5Dcreate (group_hid, "fcn",  type_hid, space_hid,
 			    H5P_DEFAULT);
       if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL,
-				    H5P_DEFAULT,
-				    X_CAST (void *, stmp.c_str ())) < 0)
+				    H5P_DEFAULT, stmp.c_str ()) < 0)
 	{
 	  H5Sclose (space_hid);
 	  H5Tclose (type_hid);
@@ -422,8 +420,7 @@
   st_id = H5Tcopy (H5T_C_S1);
   H5Tset_size (st_id, slen);
 
-  if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-	       X_CAST (void *, nm_tmp)) < 0)
+  if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, nm_tmp) < 0)
     {
       H5Sclose (space_hid);
       H5Tclose (type_hid);
@@ -483,8 +480,7 @@
       st_id = H5Tcopy (H5T_C_S1);
       H5Tset_size (st_id, slen);
 
-      if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-		   X_CAST (void *, fcn_tmp)) < 0)
+      if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, fcn_tmp) < 0)
 	{
 	  H5Sclose (space_hid);
 	  H5Tclose (type_hid);
--- a/src/ov-fcn-inline.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-fcn-inline.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -157,18 +157,18 @@
 octave_fcn_inline::save_binary (std::ostream& os, bool&)
 {
   FOUR_BYTE_INT tmp = ifargs.length ();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < ifargs.length (); i++)
     {
       tmp = ifargs(i).length ();
-      os.write (X_CAST (char *, &tmp), 4);
+      os.write (reinterpret_cast<char *> (&tmp), 4);
       os.write (ifargs(i).c_str (), ifargs(i).length ());
     }
   tmp = nm.length ();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   os.write (nm.c_str (), nm.length ());
   tmp = iftext.length ();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   os.write (iftext.c_str (), iftext.length ());
   return true;
 }
@@ -178,7 +178,7 @@
 				oct_mach_info::float_format)
 {
   FOUR_BYTE_INT nargs;
-  if (! is.read (X_CAST (char *, &nargs), 4))
+  if (! is.read (reinterpret_cast<char *> (&nargs), 4))
     return false;
   if (swap)
     swap_bytes<4> (&nargs);
@@ -191,7 +191,7 @@
       ifargs.resize (nargs);
       for (int i = 0; i < nargs; i++)
 	{
-	  if (! is.read (X_CAST (char *, &tmp), 4))
+	  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	    return false;
 	  if (swap)
 	    swap_bytes<4> (&tmp);
@@ -204,7 +204,7 @@
 	    return false;
 	}
 
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
@@ -216,7 +216,7 @@
       if (! is)
 	return false;
 
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
@@ -309,7 +309,7 @@
     }
 
   hdims[0] = 0;
-  space_hid = H5Screate_simple (0 , hdims, (hsize_t*) 0);
+  space_hid = H5Screate_simple (0 , hdims, 0);
   if (space_hid < 0)
     {
       H5Tclose (type_hid);
@@ -319,7 +319,7 @@
 
   data_hid = H5Dcreate (group_hid, "nm",  type_hid, space_hid, H5P_DEFAULT);
   if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL,
-				H5P_DEFAULT, (void*) nm.c_str ()) < 0)
+				H5P_DEFAULT, nm.c_str ()) < 0)
     {
       H5Sclose (space_hid);
       H5Tclose (type_hid);
@@ -339,7 +339,7 @@
   data_hid = H5Dcreate (group_hid, "iftext",  type_hid, space_hid,
 			H5P_DEFAULT);
   if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL,
-				H5P_DEFAULT, (void*) iftext.c_str ()) < 0)
+				H5P_DEFAULT, iftext.c_str ()) < 0)
     {
       H5Sclose (space_hid);
       H5Tclose (type_hid);
@@ -449,8 +449,7 @@
   st_id = H5Tcopy (H5T_C_S1);
   H5Tset_size (st_id, slen);
 
-  if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-	       X_CAST (void *, nm_tmp)) < 0)
+  if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, nm_tmp) < 0)
     {
       H5Sclose (space_hid);
       H5Tclose (type_hid);
@@ -508,8 +507,7 @@
   st_id = H5Tcopy (H5T_C_S1);
   H5Tset_size (st_id, slen);
 
-  if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-	       X_CAST (void *, iftext_tmp)) < 0)
+  if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, iftext_tmp) < 0)
     {
       H5Sclose (space_hid);
       H5Tclose (type_hid);
--- a/src/ov-list.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-list.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -618,7 +618,7 @@
   octave_value_list lst = list_value ();
 
   FOUR_BYTE_INT len = lst.length();
-  os.write (X_CAST (char *, &len), 4);
+  os.write (reinterpret_cast<char *> (&len), 4);
   
   for (int i = 0; i < lst.length (); i++)
     {
@@ -642,10 +642,10 @@
 
 bool 
 octave_list::load_binary (std::istream& is, bool swap,
-				 oct_mach_info::float_format fmt)
+			  oct_mach_info::float_format fmt)
 {
   FOUR_BYTE_INT len;
-  if (! is.read (X_CAST (char *, &len), 4))
+  if (! is.read (reinterpret_cast<char *> (&len), 4))
     return false;
   if (swap)
     swap_bytes<4> (&len);
--- a/src/ov-range.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-range.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -326,15 +326,15 @@
 bool 
 octave_range::save_binary (std::ostream& os, bool& /* save_as_floats */)
 {
-  char tmp = (char) LS_DOUBLE;
-  os.write (X_CAST (char *, &tmp), 1);
+  char tmp = LS_DOUBLE;
+  os.write (reinterpret_cast<char *> (&tmp), 1);
   Range r = range_value ();
   double bas = r.base ();
   double lim = r.limit ();
   double inc = r.inc ();
-  os.write (X_CAST (char *, &bas), 8);
-  os.write (X_CAST (char *, &lim), 8);
-  os.write (X_CAST (char *, &inc), 8);
+  os.write (reinterpret_cast<char *> (&bas), 8);
+  os.write (reinterpret_cast<char *> (&lim), 8);
+  os.write (reinterpret_cast<char *> (&inc), 8);
 
   return true;
 }
@@ -344,18 +344,18 @@
 			   oct_mach_info::float_format /* fmt */)
 {
   char tmp;
-  if (! is.read (X_CAST (char *, &tmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
     return false;
   double bas, lim, inc;
-  if (! is.read (X_CAST (char *, &bas), 8))
+  if (! is.read (reinterpret_cast<char *> (&bas), 8))
     return false;
   if (swap)
     swap_bytes<8> (&bas);
-  if (! is.read (X_CAST (char *, &lim), 8))
+  if (! is.read (reinterpret_cast<char *> (&lim), 8))
     return false;
   if (swap)
     swap_bytes<8> (&lim);
-  if (! is.read (X_CAST (char *, &inc), 8))
+  if (! is.read (reinterpret_cast<char *> (&inc), 8))
     return false;
   if (swap)
     swap_bytes<8> (&inc);
--- a/src/ov-re-mat.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-re-mat.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -433,11 +433,11 @@
 
   // Use negative value for ndims to differentiate with old format!!
   FOUR_BYTE_INT tmp = - d.length();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
       tmp = d(i);
-      os.write (X_CAST (char *, &tmp), 4);
+      os.write (reinterpret_cast<char *> (&tmp), 4);
     }
 
   NDArray m = array_value ();
@@ -471,7 +471,7 @@
 {
   char tmp;
   FOUR_BYTE_INT mdims;
-  if (! is.read (X_CAST (char *, &mdims), 4))
+  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
     return false;
   if (swap)
     swap_bytes<4> (&mdims);
@@ -484,7 +484,7 @@
 
       for (int i = 0; i < mdims; i++)
 	{
-	  if (! is.read (X_CAST (char *, &di), 4))
+	  if (! is.read (reinterpret_cast<char *> (&di), 4))
 	    return false;
 	  if (swap)
 	    swap_bytes<4> (&di);
@@ -503,12 +503,12 @@
 	  dv(0) = 1;
 	}
 
-      if (! is.read (X_CAST (char *, &tmp), 1))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 1))
 	return false;
 
       NDArray m(dv);
       double *re = m.fortran_vec ();
-      read_doubles (is, re, X_CAST (save_type, tmp), dv.numel (), swap, fmt);
+      read_doubles (is, re, static_cast<save_type> (tmp), dv.numel (), swap, fmt);
       if (error_state || ! is)
 	return false;
       matrix = m;
@@ -517,16 +517,16 @@
     {
       FOUR_BYTE_INT nr, nc;
       nr = mdims;
-      if (! is.read (X_CAST (char *, &nc), 4))
+      if (! is.read (reinterpret_cast<char *> (&nc), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&nc);
-      if (! is.read (X_CAST (char *, &tmp), 1))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 1))
 	return false;
       Matrix m (nr, nc);
       double *re = m.fortran_vec ();
       octave_idx_type len = nr * nc;
-      read_doubles (is, re, X_CAST (save_type, tmp), len, swap, fmt);
+      read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
       if (error_state || ! is)
 	return false;
       matrix = m;
--- a/src/ov-re-sparse.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-re-sparse.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -261,16 +261,16 @@
   FOUR_BYTE_INT itmp;
   // Use negative value for ndims to be consistent with other formats
   itmp= -2;        
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nr;    
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nc;
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
   
   itmp= nz;
-  os.write (X_CAST (char *, &itmp), 4);
+  os.write (reinterpret_cast<char *> (&itmp), 4);
 
   save_type st = LS_DOUBLE;
   if (save_as_floats)
@@ -296,14 +296,14 @@
      {
        OCTAVE_QUIT;
        itmp = matrix.cidx(i);
-       os.write (X_CAST (char *, &itmp), 4);
+       os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
    for (int i = 0; i < nz; i++) 
      {
        OCTAVE_QUIT;
        itmp = matrix.ridx(i); 
-       os.write (X_CAST (char *, &itmp), 4);
+       os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
    write_doubles (os, matrix.data(), st, nz);
@@ -318,7 +318,7 @@
   FOUR_BYTE_INT nz, nc, nr, tmp;
   char ctmp;
 
-  if (! is.read (X_CAST (char *, &tmp), 4))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
     return false;
 
   if (swap)
@@ -329,11 +329,11 @@
     return false;
   }
 
-  if (! is.read (X_CAST (char *, &nr), 4))
+  if (! is.read (reinterpret_cast<char *> (&nr), 4))
     return false;
-  if (! is.read (X_CAST (char *, &nc), 4))
+  if (! is.read (reinterpret_cast<char *> (&nc), 4))
     return false;
-  if (! is.read (X_CAST (char *, &nz), 4))
+  if (! is.read (reinterpret_cast<char *> (&nz), 4))
     return false;
 
   if (swap)
@@ -350,7 +350,7 @@
   for (int i = 0; i < nc+1; i++) 
     {
       OCTAVE_QUIT;
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
@@ -360,17 +360,17 @@
   for (int i = 0; i < nz; i++) 
     {
       OCTAVE_QUIT;
-      if (! is.read (X_CAST (char *, &tmp), 4))
+      if (! is.read (reinterpret_cast<char *> (&tmp), 4))
 	return false;
       if (swap)
 	swap_bytes<4> (&tmp);
       m.xridx(i) = tmp;
     }
 
-  if (! is.read (X_CAST (char *, &ctmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&ctmp), 1))
     return false;
   
-  read_doubles (is, m.xdata (), X_CAST (save_type, ctmp), nz, swap, fmt);
+  read_doubles (is, m.xdata (), static_cast<save_type> (ctmp), nz, swap, fmt);
 
   if (error_state || ! is)
     return false;
@@ -402,7 +402,7 @@
   octave_idx_type tmp;
   hsize_t hdims[2];
 
-  space_hid = H5Screate_simple (0, hdims, (hsize_t*) 0);
+  space_hid = H5Screate_simple (0, hdims, 0);
   if (space_hid < 0) 
     {
       H5Gclose (group_hid);
@@ -420,7 +420,7 @@
   
   tmp = m.rows ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-		     (void*) &tmp) >= 0;
+		     &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -440,7 +440,7 @@
   
   tmp = m.cols ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-		     (void*) &tmp) >= 0;
+		     &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -460,7 +460,7 @@
   
   tmp = m.nzmax ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-		     (void*) &tmp) >= 0;
+		     &tmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -493,7 +493,7 @@
   
   octave_idx_type * itmp = m.xcidx ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-		     (void*) itmp) >= 0;
+		     itmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -526,7 +526,7 @@
   
   itmp = m.xridx ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, H5P_DEFAULT,
-		     (void*) itmp) >= 0;
+		     itmp) >= 0;
   H5Dclose (data_hid);
   if (!retval)
     {
@@ -570,7 +570,7 @@
   
   double * dtmp = m.xdata ();
   retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL,
-		     H5P_DEFAULT, (void*) dtmp) >= 0;
+		     H5P_DEFAULT, dtmp) >= 0;
   H5Dclose (data_hid);
   H5Sclose (space_hid);
   H5Gclose (group_hid);
@@ -580,7 +580,7 @@
 
 bool
 octave_sparse_matrix::load_hdf5 (hid_t loc_id, const char *name,
-				      bool /* have_h5giterate_bug */)
+				 bool /* have_h5giterate_bug */)
 {
   octave_idx_type nr, nc, nz;
   hid_t group_hid, data_hid, space_hid;
@@ -594,7 +594,7 @@
     return (empty > 0);
   
   group_hid = H5Gopen (loc_id, name);
-  if (group_hid < 0 ) return false;
+  if (group_hid < 0) return false;
 
   data_hid = H5Dopen (group_hid, "nr");
   space_hid = H5Dget_space (data_hid);
@@ -608,7 +608,7 @@
     }
 
   if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nr) < 0)
+	       H5P_DEFAULT, &nr) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -629,7 +629,7 @@
     }
 
   if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nc) < 0)
+	       H5P_DEFAULT, &nc) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -650,7 +650,7 @@
     }
 
   if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) &nz) < 0)
+	       H5P_DEFAULT, &nz) < 0)
     { 
       H5Dclose (data_hid);
       H5Gclose (group_hid);
@@ -691,7 +691,7 @@
 
   octave_idx_type *itmp = m.xcidx ();
   if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) itmp) < 0) 
+	       H5P_DEFAULT, itmp) < 0) 
     {
       H5Sclose (space_hid);
       H5Dclose (data_hid);
@@ -726,7 +726,7 @@
 
   itmp = m.xridx ();
   if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) itmp) < 0) 
+	       H5P_DEFAULT, itmp) < 0) 
     {
       H5Sclose (space_hid);
       H5Dclose (data_hid);
@@ -761,7 +761,7 @@
 
   double *dtmp = m.xdata ();
   if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, 
-	       H5P_DEFAULT, (void *) dtmp) < 0) 
+	       H5P_DEFAULT, dtmp) < 0) 
     {
       H5Sclose (space_hid);
       H5Dclose (data_hid);
--- a/src/ov-scalar.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-scalar.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -206,10 +206,10 @@
 bool 
 octave_scalar::save_binary (std::ostream& os, bool& /* save_as_floats */)
 {
-  char tmp = (char) LS_DOUBLE;
-  os.write (X_CAST (char *, &tmp), 1);
+  char tmp = LS_DOUBLE;
+  os.write (reinterpret_cast<char *> (&tmp), 1);
   double dtmp = double_value ();
-  os.write (X_CAST (char *, &dtmp), 8);
+  os.write (reinterpret_cast<char *> (&dtmp), 8);
 
   return true;
 }
@@ -219,11 +219,11 @@
 			    oct_mach_info::float_format fmt)
 {
   char tmp;
-  if (! is.read (X_CAST (char *, &tmp), 1))
+  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
     return false;
 
   double dtmp;
-  read_doubles (is, &dtmp, X_CAST (save_type, tmp), 1, swap, fmt);
+  read_doubles (is, &dtmp, static_cast<save_type> (tmp), 1, swap, fmt);
   if (error_state || ! is)
     return false;
 
--- a/src/ov-str-mat.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-str-mat.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -287,7 +287,7 @@
       for (int i=0; i < d.length (); i++)
 	os << " " << d (i);
       os << "\n";
-      os.write (X_CAST (char *, tmp.fortran_vec ()), d.numel ());
+      os.write (tmp.fortran_vec (), d.numel ());
       os << "\n";
     }
   else
@@ -305,7 +305,7 @@
 	  const char *tmp = tstr.data ();
 	  if (tstr.length () > len)
 	    panic_impossible ();
-	  os.write (X_CAST (char *, tmp), len);
+	  os.write (tmp, len);
 	  os << "\n";
 	}
     }
@@ -381,7 +381,7 @@
 		      OCTAVE_LOCAL_BUFFER (char, tmp, len+1);
 		  
 		      if (len > 0 && ! 
-			  is.read (X_CAST (char *, tmp), len))
+			  is.read (tmp, len))
 			{
 			  error ("load: failed to load string constant");
 			  success = false;
@@ -426,7 +426,7 @@
 
 	      OCTAVE_LOCAL_BUFFER (char, tmp, len+1);
 
-	      if (len > 0 && ! is.read (X_CAST (char *, tmp), len))
+	      if (len > 0 && ! is.read (tmp, len))
 		{
 		  error ("load: failed to load string constant");
 		}
@@ -463,11 +463,11 @@
 
   // Use negative value for ndims to differentiate with old format!!
   FOUR_BYTE_INT tmp = - d.length();
-  os.write (X_CAST (char *, &tmp), 4);
+  os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i=0; i < d.length (); i++)
     {
       tmp = d(i);
-      os.write (X_CAST (char *, &tmp), 4);
+      os.write (reinterpret_cast<char *> (&tmp), 4);
     }
 
   charNDArray m = char_array_value ();
@@ -480,7 +480,7 @@
 				     oct_mach_info::float_format /* fmt */)
 {
   FOUR_BYTE_INT elements;
-  if (! is.read (X_CAST (char *, &elements), 4))
+  if (! is.read (reinterpret_cast<char *> (&elements), 4))
     return false;
   if (swap)
     swap_bytes<4> (&elements);
@@ -494,7 +494,7 @@
 
       for (int i = 0; i < mdims; i++)
 	{
-	  if (! is.read (X_CAST (char *, &di), 4))
+	  if (! is.read (reinterpret_cast<char *> (&di), 4))
 	    return false;
 	  if (swap)
 	    swap_bytes<4> (&di);
@@ -528,12 +528,12 @@
       for (int i = 0; i < elements; i++)
 	{
 	  FOUR_BYTE_INT len;
-	  if (! is.read (X_CAST (char *, &len), 4))
+	  if (! is.read (reinterpret_cast<char *> (&len), 4))
 	    return false;
 	  if (swap)
 	    swap_bytes<4> (&len);
 	  OCTAVE_LOCAL_BUFFER (char, btmp, len+1);
-	  if (! is.read (X_CAST (char *, btmp), len))
+	  if (! is.read (reinterpret_cast<char *> (btmp), len))
 	    return false;
 	  if (len > max_len)
 	    {
@@ -680,8 +680,7 @@
 	      // to read into:
 	      hid_t st_id = H5Tcopy (H5T_C_S1);
 	      H5Tset_size (st_id, slen);
-	      if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, 
-			   H5P_DEFAULT, (void *) s) < 0)
+	      if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, s) < 0)
 		{
 		  H5Tclose (st_id);
 		  H5Tclose (type_hid);
@@ -725,8 +724,7 @@
 	      hid_t st_id = H5Tcopy (H5T_C_S1);
 	      H5Tset_size (st_id, slen);
 
-	      if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, 
-			   H5P_DEFAULT, (void *) s) < 0)
+	      if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, s) < 0)
 		{
 		  H5Tclose (st_id);
 		  H5Tclose (type_hid);
--- a/src/ov-struct.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-struct.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -1108,7 +1108,7 @@
   Octave_map m = map_value ();
 
   FOUR_BYTE_INT len = m.length();
-  os.write (X_CAST (char *, &len), 4);
+  os.write (reinterpret_cast<char *> (&len), 4);
   
   Octave_map::iterator i = m.begin ();
   while (i != m.end ())
@@ -1128,11 +1128,11 @@
 
 bool 
 octave_struct::load_binary (std::istream& is, bool swap,
-				 oct_mach_info::float_format fmt)
+			    oct_mach_info::float_format fmt)
 {
   bool success = true;
   FOUR_BYTE_INT len;
-  if (! is.read (X_CAST (char *, &len), 4))
+  if (! is.read (reinterpret_cast<char *> (&len), 4))
     return false;
   if (swap)
     swap_bytes<4> (&len);
--- a/src/ov-typeinfo.h	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/ov-typeinfo.h	Fri Apr 14 04:01:40 2006 +0000
@@ -154,20 +154,15 @@
   octave_value_typeinfo (void)
     : num_types (0), types (init_tab_sz, std::string ()),
       vals (init_tab_sz),
-      unary_ops (octave_value::num_unary_ops, init_tab_sz,
-		 (unary_op_fcn) 0),
-      non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz,
-			   (non_const_unary_op_fcn) 0),
-      binary_ops (octave_value::num_binary_ops, init_tab_sz,
-		  init_tab_sz, (binary_op_fcn) 0),
-      cat_ops (init_tab_sz, init_tab_sz, (cat_op_fcn) 0),
-      assign_ops (octave_value::num_assign_ops, init_tab_sz,
-		  init_tab_sz, (assign_op_fcn) 0),
-      assignany_ops (octave_value::num_assign_ops, init_tab_sz,
-		     (assignany_op_fcn) 0),
+      unary_ops (octave_value::num_unary_ops, init_tab_sz, 0),
+      non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, 0),
+      binary_ops (octave_value::num_binary_ops, init_tab_sz, init_tab_sz, 0),
+      cat_ops (init_tab_sz, init_tab_sz, 0),
+      assign_ops (octave_value::num_assign_ops, init_tab_sz, init_tab_sz, 0),
+      assignany_ops (octave_value::num_assign_ops, init_tab_sz, 0),
       pref_assign_conv (init_tab_sz, init_tab_sz, -1),
-      type_conv_ops (init_tab_sz, init_tab_sz, (octave_base_value::type_conv_fcn) 0),
-      widening_ops (init_tab_sz, init_tab_sz, (octave_base_value::type_conv_fcn) 0)  { }
+      type_conv_ops (init_tab_sz, init_tab_sz, 0),
+      widening_ops (init_tab_sz, init_tab_sz, 0)  { }
 
 private:
 
--- a/src/parse.y	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/parse.y	Fri Apr 14 04:01:40 2006 +0000
@@ -3113,7 +3113,7 @@
 	  if (! have_help_text)
 	    {
 	      first_comments_seen = true;
-	      help_txt += (char) c;
+	      help_txt += static_cast<char> (c);
 	    }
 
 	  if (c == '\n')
@@ -3213,7 +3213,7 @@
 
       if (fptr)
 	{
-	  unwind_protect::add (safe_fclose, (void *) fptr);
+	  unwind_protect::add (safe_fclose, fptr);
 
 	  retval = gobble_leading_white_space (fptr, true, true, false);
 
@@ -3330,8 +3330,8 @@
 	  YY_BUFFER_STATE old_buf = current_buffer ();
 	  YY_BUFFER_STATE new_buf = create_buffer (ffile);
 
-	  unwind_protect::add (restore_input_buffer, (void *) old_buf);
-	  unwind_protect::add (delete_input_buffer, (void *) new_buf);
+	  unwind_protect::add (restore_input_buffer, old_buf);
+	  unwind_protect::add (delete_input_buffer, new_buf);
 
 	  switch_to_buffer (new_buf);
 
--- a/src/pt-arg-list.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/pt-arg-list.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -171,7 +171,7 @@
     {
       unwind_protect::begin_frame ("convert_to_const_vector");
 
-      unwind_protect_ptr (indexed_object);
+      unwind_protect_const_ptr (indexed_object);
 
       indexed_object = object;
     }
--- a/src/pt-pr-code.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/pt-pr-code.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -1188,7 +1188,7 @@
 		os << " ";
 	    }
 
-	  os << (char) c;
+	  os << static_cast<char> (c);
 
 	  prev_char_was_newline = false;
 	}
--- a/src/symtab.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/symtab.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -1210,8 +1210,8 @@
 static int
 maybe_list_cmp_fcn (const void *a_arg, const void *b_arg)
 {
-  const symbol_record *a = *(X_CAST (const symbol_record **, a_arg));
-  const symbol_record *b = *(X_CAST (const symbol_record **, b_arg));
+  const symbol_record *a = static_cast<const symbol_record *> (a_arg);
+  const symbol_record *b = static_cast<const symbol_record *> (b_arg);
 
   std::string a_nm = a->name ();
   std::string b_nm = b->name ();
--- a/src/unwind-prot.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/unwind-prot.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -79,7 +79,7 @@
     {
       bool bool_value;
       int int_value;
-      const std::string *str_value;
+      std::string *str_value;
       void *gen_ptr_value;
     };
 
--- a/src/unwind-prot.h	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/unwind-prot.h	Fri Apr 14 04:01:40 2006 +0000
@@ -122,7 +122,12 @@
   unwind_protect::save_str (&(s), (s))
 
 #define unwind_protect_ptr(p) \
-  unwind_protect::save_ptr (X_CAST (void **, &(p)), X_CAST (void *, (p)))
+  unwind_protect::save_ptr (reinterpret_cast<void **> (&(p)), \
+                            reinterpret_cast<void *> (p))
+
+#define unwind_protect_const_ptr(p) \
+  unwind_protect::save_ptr (const_cast<void **> (reinterpret_cast<const void **> (&(p))), \
+                            const_cast<void *> (reinterpret_cast<const void *> (p)))
 
 #endif
 
--- a/src/variables.cc	Thu Apr 13 13:04:33 2006 +0000
+++ b/src/variables.cc	Fri Apr 14 04:01:40 2006 +0000
@@ -1463,8 +1463,8 @@
 static int
 symbol_record_name_compare (const void *a_arg, const void *b_arg)
 {
-  const symbol_record *a = *(X_CAST (const symbol_record **, a_arg));
-  const symbol_record *b = *(X_CAST (const symbol_record **, b_arg));
+  const symbol_record *a = static_cast<const symbol_record *> (a_arg);
+  const symbol_record *b = static_cast<const symbol_record *> (b_arg);
 
   std::string a_nm = a->name ();
   std::string b_nm = b->name ();