traits<Ref>::match: use correct strides
diff --git a/Eigen/src/Core/Ref.h b/Eigen/src/Core/Ref.h
index df43c05..5be39ce 100644
--- a/Eigen/src/Core/Ref.h
+++ b/Eigen/src/Core/Ref.h
@@ -26,7 +26,9 @@
   enum {
     Options = Options_,
     Flags = traits<Map<PlainObjectType_, Options_, StrideType_> >::Flags | NestByRefBit,
-    Alignment = traits<Map<PlainObjectType_, Options_, StrideType_> >::Alignment
+    Alignment = traits<Map<PlainObjectType_, Options_, StrideType_> >::Alignment,
+    InnerStrideAtCompileTime = traits<Map<PlainObjectType_, Options_, StrideType_> >::InnerStrideAtCompileTime,
+    OuterStrideAtCompileTime = traits<Map<PlainObjectType_, Options_, StrideType_> >::OuterStrideAtCompileTime
   };
 
   template<typename Derived> struct match {
@@ -34,11 +36,11 @@
       IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime,
       HasDirectAccess = internal::has_direct_access<Derived>::ret,
       StorageOrderMatch = IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)),
-      InnerStrideMatch = int(StrideType::InnerStrideAtCompileTime)==int(Dynamic)
-                      || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)
-                      || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),
+      InnerStrideMatch = int(InnerStrideAtCompileTime)==int(Dynamic)
+                      || int(InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)
+                      || (int(InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),
       OuterStrideMatch = IsVectorAtCompileTime
-                      || int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),
+                      || int(OuterStrideAtCompileTime)==int(Dynamic) || int(OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),
       // NOTE, this indirection of evaluator<Derived>::Alignment is needed
       // to workaround a very strange bug in MSVC related to the instantiation
       // of has_*ary_operator in evaluator<CwiseNullaryOp>.
diff --git a/test/ref.cpp b/test/ref.cpp
index f283537..f0faa94 100644
--- a/test/ref.cpp
+++ b/test/ref.cpp
@@ -341,6 +341,17 @@
   VERIFY(test_is_equal(data1, obj_data2, MatrixType::MaxSizeAtCompileTime == Dynamic && owns_data));
 }
 
+template <typename MatrixType>
+void test_contiguous_ref_no_copy(const PlainObjectBase<MatrixType> &obj) {
+  typedef Ref<MatrixType, Unaligned, Stride<0, 0>> Ref_;
+  typedef Ref<const MatrixType, Unaligned, Stride<0, 0>> CRef_;
+  MatrixType m(obj);
+  Ref_ ref(m);
+  VERIFY(test_is_equal(ref.data(), m.data(), true));
+  CRef_ cref(m);
+  VERIFY(test_is_equal(cref.data(), m.data(), true));
+}
+
 EIGEN_DECLARE_TEST(ref)
 {
   for(int i = 0; i < g_repeat; i++) {
@@ -375,4 +386,8 @@
   CALL_SUBTEST_9( test_cref_move_ctor<MatrixXd>(MatrixXd(9, 5)) );
   CALL_SUBTEST_9( test_cref_move_ctor<Matrix3d>(Matrix3d::Ones()) );
   CALL_SUBTEST_9( test_cref_move_ctor<Matrix3d>(Matrix3d()) );
+  CALL_SUBTEST_10(test_contiguous_ref_no_copy(VectorXd(9)));
+  CALL_SUBTEST_10(test_contiguous_ref_no_copy(Vector3d()));
+  CALL_SUBTEST_10(test_contiguous_ref_no_copy(MatrixXd(9, 5)));
+  CALL_SUBTEST_10(test_contiguous_ref_no_copy(Matrix3d()));
 }