diff -r 121e9639b604 liboctave/array/CMatrix.cc
--- a/liboctave/array/CMatrix.cc	Thu Sep 29 15:44:54 2016 -0700
+++ b/liboctave/array/CMatrix.cc	Fri Sep 30 19:22:05 2016 +0300
@@ -2415,6 +2415,7 @@
       double dminmn = static_cast<double> (minmn);
       double dsmlsizp1 = static_cast<double> (smlsiz+1);
       double tmp = octave::math::log2 (dminmn / dsmlsizp1);
+      double anorm = 0.0;
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2473,18 +2474,27 @@
       lwork = static_cast<octave_idx_type> (octave::math::real (work(0)));
       work.resize (dim_vector (lwork, 1));
 
-      F77_XFCN (zgelsd, ZGELSD, (m, n, nrhs, F77_DBLE_CMPLX_ARG (tmp_data), m,
+//    workaround for bug #39000
+      anorm = xnorm (*this, 1);
+      if (octave::math::isinf (anorm) || octave::math::isnan (anorm)) {
+        rcon = 0.0;
+        octave::warn_singular_matrix ();
+        retval = Matrix (n, m, 0.0);
+      }
+      else { 
+        F77_XFCN (zgelsd, ZGELSD, (m, n, nrhs, F77_DBLE_CMPLX_ARG (tmp_data), m,
                                  F77_DBLE_CMPLX_ARG (pretval),
                                  maxmn, ps, rcon, rank,
                                  F77_DBLE_CMPLX_ARG (work.fortran_vec ()), lwork,
                                  prwork, piwork, info));
 
-      if (s.elem (0) == 0.0)
-        rcon = 0.0;
-      else
-        rcon = s.elem (minmn - 1) / s.elem (0);
-
-      retval.resize (n, nrhs);
+        if (s.elem (0) == 0.0)
+          rcon = 0.0;
+        else
+          rcon = s.elem (minmn - 1) / s.elem (0);
+
+        retval.resize (n, nrhs);
+      }
     }
 
   return retval;
diff -r 121e9639b604 liboctave/array/dMatrix.cc
--- a/liboctave/array/dMatrix.cc	Thu Sep 29 15:44:54 2016 -0700
+++ b/liboctave/array/dMatrix.cc	Fri Sep 30 19:22:05 2016 +0300
@@ -2076,6 +2076,7 @@
       double dminmn = static_cast<double> (minmn);
       double dsmlsizp1 = static_cast<double> (smlsiz+1);
       double tmp = octave::math::log2 (dminmn / dsmlsizp1);
+      double anorm = 0.0;
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2131,17 +2132,26 @@
       lwork = static_cast<octave_idx_type> (work(0));
       work.resize (dim_vector (lwork, 1));
 
-      F77_XFCN (dgelsd, DGELSD, (m, n, nrhs, tmp_data, m, pretval,
+//    workaround for bug #39000
+      anorm = xnorm (*this, 1);
+      if (octave::math::isinf (anorm) || octave::math::isnan (anorm)) {
+        rcon = 0.0;
+        octave::warn_singular_matrix ();
+        retval = Matrix (n, m, 0.0);
+      }
+      else {
+        F77_XFCN (dgelsd, DGELSD, (m, n, nrhs, tmp_data, m, pretval,
                                  maxmn, ps, rcon, rank,
                                  work.fortran_vec (), lwork,
                                  piwork, info));
 
-      if (s.elem (0) == 0.0)
-        rcon = 0.0;
-      else
-        rcon = s.elem (minmn - 1) / s.elem (0);
-
-      retval.resize (n, nrhs);
+        if (s.elem (0) == 0.0)
+          rcon = 0.0;
+        else
+          rcon = s.elem (minmn - 1) / s.elem (0);
+
+        retval.resize (n, nrhs);
+      }
     }
 
   return retval;
diff -r 121e9639b604 liboctave/array/fCMatrix.cc
--- a/liboctave/array/fCMatrix.cc	Thu Sep 29 15:44:54 2016 -0700
+++ b/liboctave/array/fCMatrix.cc	Fri Sep 30 19:22:05 2016 +0300
@@ -2432,6 +2432,7 @@
       float dminmn = static_cast<float> (minmn);
       float dsmlsizp1 = static_cast<float> (smlsiz+1);
       float tmp = octave::math::log2 (dminmn / dsmlsizp1);
+      float anorm = 0.0;
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2490,18 +2491,27 @@
       lwork = static_cast<octave_idx_type> (octave::math::real (work(0)));
       work.resize (dim_vector (lwork, 1));
 
-      F77_XFCN (cgelsd, CGELSD, (m, n, nrhs, F77_CMPLX_ARG (tmp_data), m,
+//    workaround for bug #39000
+      anorm = xnorm (*this, 1);
+      if (octave::math::isinf (anorm) || octave::math::isnan (anorm)) {
+        rcon = 0.0;
+        octave::warn_singular_matrix ();
+        retval = Matrix (n, m, 0.0);
+      }
+      else { 
+        F77_XFCN (cgelsd, CGELSD, (m, n, nrhs, F77_CMPLX_ARG (tmp_data), m,
                                  F77_CMPLX_ARG (pretval),
                                  maxmn, ps, rcon, rank,
                                  F77_CMPLX_ARG (work.fortran_vec ()), lwork,
                                  prwork, piwork, info));
 
-      if (s.elem (0) == 0.0)
-        rcon = 0.0;
-      else
-        rcon = s.elem (minmn - 1) / s.elem (0);
-
-      retval.resize (n, nrhs);
+        if (s.elem (0) == 0.0)
+          rcon = 0.0;
+        else
+          rcon = s.elem (minmn - 1) / s.elem (0);
+
+        retval.resize (n, nrhs);
+      }
     }
 
   return retval;
diff -r 121e9639b604 liboctave/array/fMatrix.cc
--- a/liboctave/array/fMatrix.cc	Thu Sep 29 15:44:54 2016 -0700
+++ b/liboctave/array/fMatrix.cc	Fri Sep 30 19:22:05 2016 +0300
@@ -2103,6 +2103,7 @@
       float dminmn = static_cast<float> (minmn);
       float dsmlsizp1 = static_cast<float> (smlsiz+1);
       float tmp = octave::math::log2 (dminmn / dsmlsizp1);
+      float anorm = 0.0;
 
       octave_idx_type nlvl = static_cast<octave_idx_type> (tmp) + 1;
       if (nlvl < 0)
@@ -2158,17 +2159,26 @@
       lwork = static_cast<octave_idx_type> (work(0));
       work.resize (dim_vector (lwork, 1));
 
-      F77_XFCN (sgelsd, SGELSD, (m, n, nrhs, tmp_data, m, pretval,
+//    workaround for bug #39000
+      anorm = xnorm (*this, 1);
+      if (octave::math::isinf (anorm) || octave::math::isnan (anorm)) {
+        rcon = 0.0;
+        octave::warn_singular_matrix ();
+        retval = Matrix (n, m, 0.0);
+      }
+      else {
+        F77_XFCN (sgelsd, SGELSD, (m, n, nrhs, tmp_data, m, pretval,
                                  maxmn, ps, rcon, rank,
                                  work.fortran_vec (), lwork,
                                  piwork, info));
 
-      if (s.elem (0) == 0.0)
-        rcon = 0.0;
-      else
-        rcon = s.elem (minmn - 1) / s.elem (0);
-
-      retval.resize (n, nrhs);
+        if (s.elem (0) == 0.0)
+          rcon = 0.0;
+        else
+          rcon = s.elem (minmn - 1) / s.elem (0);
+
+        retval.resize (n, nrhs);
+      }
     }
 
   return retval;
diff -r 121e9639b604 test/bug-46330.tst
--- a/test/bug-46330.tst	Thu Sep 29 15:44:54 2016 -0700
+++ b/test/bug-46330.tst	Fri Sep 30 19:22:05 2016 +0300
@@ -17,9 +17,4 @@
 %! ## This statement caused an error in LAPACK and eventually caused
 %! ## a segmentation fault.
 %! ## Triggers "warning: matrix singular to machine precision"
-%! ## FIXME: LAPACK errors become fatal crashes on Windows, don't test this
-%! if (ispc ())
-%!   warning ("unable to test for bug #46330 on Windows");
-%! else
-%!   assert (c / (i * Inf * eye (4) - a) * b, zeros (2, 2))
-%! endif
+%! assert (c / (i * Inf * eye (4) - a) * b, zeros (2, 2))
