Skip to content
Snippets Groups Projects
Commit 46f6addc authored by Sander, Oliver's avatar Sander, Oliver
Browse files

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.
parent 22adf453
No related branches found
No related tags found
1 merge request!28Fix a few issues that I found using the clang sanitizer
Pipeline #3447 failed
...@@ -41,9 +41,8 @@ void svdcmp(Dune::FieldMatrix<T,m,n>& a_, Dune::FieldVector<T,n>& w, Dune::Field ...@@ -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]; a[i+1][j+1] = a_[i][j];
int flag,i,its,j,jj,k,l,nm; int flag,i,its,j,jj,k,l,nm;
T anorm,c,f,g,h,s,scale,x,y,z,*rv1; T anorm,c,f,g,h,s,scale,x,y,z;
T rv1_c[n]; // 1 too large to accomodate fortran numbering T rv1[n+1]; // 1 too large to accomodate fortran numbering
rv1 = rv1_c-1;
//Householder reduction to bidiagonal form. //Householder reduction to bidiagonal form.
g=scale=anorm=0.0; g=scale=anorm=0.0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment