From 46f6addc1190ce8cb1fbacf73d3ba7f92473baee Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Tue, 11 Feb 2020 13:25:10 +0100
Subject: [PATCH] Avoid undefined behavior (sanitizer warning)

The svd code contains some index trickery, because the original code
was written in fortran, which numbers arrays starting from '1'
rather than from '0'.  This trickery included having a pointer point
1 int in front of an allocated array, implicitly relying on the
fact that pointer[0] would never be called.  The llvm sanitizer
complains nevertheless, so this patch improves the trickery a little
to avoid the objected pointer.
---
 dune/gfe/svd.hh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/dune/gfe/svd.hh b/dune/gfe/svd.hh
index 3375f6bb..1f07c3c3 100644
--- a/dune/gfe/svd.hh
+++ b/dune/gfe/svd.hh
@@ -41,9 +41,8 @@ void svdcmp(Dune::FieldMatrix<T,m,n>& a_, Dune::FieldVector<T,n>& w, Dune::Field
             a[i+1][j+1] = a_[i][j];
 
     int flag,i,its,j,jj,k,l,nm;
-    T anorm,c,f,g,h,s,scale,x,y,z,*rv1;
-    T rv1_c[n];  // 1 too large to accomodate fortran numbering
-    rv1 = rv1_c-1;
+    T anorm,c,f,g,h,s,scale,x,y,z;
+    T rv1[n+1];  // 1 too large to accomodate fortran numbering
 
     //Householder reduction to bidiagonal form.
     g=scale=anorm=0.0;
-- 
GitLab