[Dune-devel] [GSoC]Updates and problems
Markus Blatt
markus at dr-blatt.de
Fri Jul 15 13:47:06 CEST 2016
Hi,
On Thu, Jul 14, 2016 at 10:07:18AM +0200, Oliver Sander wrote:
> Hi Xinyun,
> [please keep the discussions on the list.]
>
> I think your BSplineLeafIterator class needs to hold a (shared) pointer so the entity it points to,
> in addition to the directIndex. Then what 'dereference' returns is
> not a temporary anymore.
I do not agree with this fix as it might cause dangling
references. I am sure that at some point this pointer will be reset
(e.g. by operator++ being called). In this case we might have a reference to
a non-existent object or the value pointed to might be different. Both
are really hard to detect/debug. Just imagine this:
Iter iter = bla.begin();
auto& ref = *iter; // everything ok.
++iter; // Most probably resets the shared_ptr or overwrites the value
// pointed to.
Either we have a really hard to debug dangling reference or it does
not point to the spline that the user expects (second spline instead
of first).
May I ask why the BSplineGridEntity is created on demand?
If it is for a really good cause, then the iterator should not return a
reference, but a proxy object that contains a shared_ptr to it. But
the reason must be really, really, really good. std::vector<bool> does
this but it is really frowned upon.
Otherwise the question should read:
Why can't we create a container of BSplineGridEntities and thus get
rid of the problem?
Markus
>
> On 14.07.2016 00:28, Xinyun wrote:
> > Hey Oliver,
> >
> > In the past few days I tried to make the BSplineLeafIterator work
> > using the Barton-Nackman trick. You can check here
> > <http://gsoc2016xinyun.blogspot.de/2016/07/make-b-spline-grid-iterators-work.html>
> > for more details about what I intended to do. But I encountered a
> > specific programming problem which even hindered me to compile the
> > code. I have spent some time to play around but still couldn't
> > make it through. So I think it's better to ask for your help. As
> > the code still contains errors, I didn't upload it to gitlab.
But that might make commenting on code a bit easier.
Markus
--
Dr. Markus Blatt - HPC-Simulation-Software & Services http://www.dr-blatt.de
Hans-Bunte-Str. 8-10, 69123 Heidelberg, Germany
Tel.: +49 (0) 160 97590858
More information about the Dune-devel
mailing list