[Dune] [Dune-Commit] dune-localfunctions r865 - trunk/dune/localfunctions/utility

Christian Engwer christi at uni-hd.de
Fri Apr 23 20:39:18 CEST 2010


On Fri, Apr 23, 2010 at 08:17:04PM +0200, Martin Nolte wrote:
> Hi Christian,
> 
> may I inquire what this changes? What I find especially disturbing is
> the fact that the difference of two pointers should be and integer (not
> ptr_diff_t or whatever this type is called). On an amd64 machine this
> could lead to serious trouble because pointers are 64 bit and ints are
> 32 bit.

OK, you are right about this. For some reason, the distance of two
pointer was not allowed to be negative. If coeff had an address
greater than coeff_ you got a segfault.

I'll change the type of the offset...

Christian

Btw: some help with those undocumented classes would be have been nice :-(

> On 04/23/2010 08:09 PM, christi at dune-project.org wrote:
> > Author: christi
> > Date: 2010-04-23 20:09:18 +0200 (Fri, 23 Apr 2010)
> > New Revision: 865
> > 
> > Modified:
> >    trunk/dune/localfunctions/utility/coeffmatrix.hh
> > Log:
> > fix pointer arritmetics, this seems to fix FS#768
> > 
> > Modified: trunk/dune/localfunctions/utility/coeffmatrix.hh
> > ===================================================================
> > --- trunk/dune/localfunctions/utility/coeffmatrix.hh	2010-04-23 15:22:00 UTC (rev 864)
> > +++ trunk/dune/localfunctions/utility/coeffmatrix.hh	2010-04-23 18:09:18 UTC (rev 865)
> > @@ -115,10 +115,8 @@
> >          {
> >            val = 0;
> >            BasisIterator itx = x;
> > -          unsigned int c = 0;
> >            for( ; pos != rows_[ row+1 ]; ++pos, ++skipIt )
> >            {
> > -            c += *skipIt;
> >              itx += *skipIt;
> >              val.axpy(*pos,*itx);
> >            }
> > @@ -203,7 +201,10 @@
> >          skip_[i] = skip[i];
> >        }
> >        for (unsigned int i=0;i<=numRows_;++i)
> > -        rows_[i] += (coeff_-coeff);
> > +      {
> > +        int offset = ( rows_[i] - coeff);
> > +        rows_[i] = coeff_ + offset;
> > +      }
> >        
> >        delete [] coeff;
> >        delete [] skip;
> > 
> > 
> > _______________________________________________
> > Dune-Commit mailing list
> > Dune-Commit at dune-project.org
> > http://lists.dune-project.org/mailman/listinfo/dune-commit
> 




More information about the Dune mailing list