From 2abb3bd4f19534e6ba7b43e08d8f102456df8538 Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Fri, 20 Nov 2015 14:35:25 +0100
Subject: [PATCH] [densematrix] reenable and fix broken check, to avoid
 aliasing in mv and mtv

---
 dune/common/densematrix.hh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/dune/common/densematrix.hh b/dune/common/densematrix.hh
index d3ed73f48..47924f8f6 100644
--- a/dune/common/densematrix.hh
+++ b/dune/common/densematrix.hh
@@ -390,6 +390,7 @@ namespace Dune
     void mv (const X& x, Y& y) const
     {
 #ifdef DUNE_FMatrix_WITH_CHECKING
+      assert( (void*)(&x) != (void*)(&y) );
       if (x.N()!=M()) DUNE_THROW(FMatrixError,"Index out of range");
       if (y.N()!=N()) DUNE_THROW(FMatrixError,"Index out of range");
 #endif
@@ -406,10 +407,7 @@ namespace Dune
     void mtv ( const X &x, Y &y ) const
     {
 #ifdef DUNE_FMatrix_WITH_CHECKING
-      //assert( &x != &y );
-      //This assert did not work for me. Compile error:
-      //  comparison between distinct pointer types ‘const
-      //  Dune::FieldVector<double, 3>*’ and ‘Dune::FieldVector<double, 2>*’ lacks a cast
+      assert( (void*)(&x) != (void*)(&y) );
       if( x.N() != N() )
         DUNE_THROW( FMatrixError, "Index out of range." );
       if( y.N() != M() )
-- 
GitLab