[Dune] dune-grid does not compile when implementations of EntityPointer and Iterator are not interoperable

Steffen Müthing steffen.muething at ipvs.uni-stuttgart.de
Fri Apr 27 14:30:10 CEST 2012


Sorry, forgot the attachment...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: entitypointer-cast.patch
Type: application/octet-stream
Size: 1326 bytes
Desc: not available
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20120427/cc72e27c/attachment.obj>
-------------- next part --------------


Am 27.04.2012 um 14:09 schrieb Steffen Müthing:

> Hi Martin,
> 
> Am 27.04.2012 um 13:00 schrieb Martin Nolte:
> 
>> Hi Steffen,
>> 
>> you are right, the cast operator is indeed deprecated in the 2.1 release branch. This would mean it should be gone by now. Unfortunately, we are close to a release and I would ask the release managers whether such a change would still be in order. Is anybody still using the deprecated cast operator?
> 
> Well, regarding the cast operator: It is one of the major roadblocks towards strict aliasing support, and AFAIK
> the only one that might be directly visible to users. Looking at the release, we have the following options:
> 
> 1) Completely remove the cast (perhaps with an optional configure flag to keep it one more round).
> 2) Change the implementation to work correctly for non-interoperable types. This would make it possible for grid
>  implementors to selectively disable the cast for their grids, which might simplify implementations (see e.g. your
>  comment about the required memory layout of EntityPointer) and possibly save users from a bunch of ugly
>  problems, while still staying backward compatible.
> 3) Leave everything as it is now.
> 
> If I had a vote, I would pick 1). Regarding 2) or 3), I simply don't know enough about the original intentions
> behind the current code, so that's up to the developers to decide.
> 
> I noticed a missing const in my patch, an updated version is attached.
> 
>> 
>> For the casting problem, you might want to have a look at GeometryGrid's entity pointer (see dune/grid/geometrygrid/entitypointer.hh). Here, the entity pointer stores the host iterator (which could, e.g., be a leaf iterator). You can then derive your iterator from the entity pointer (with the correct iterator passed as template argument) and, thus, satisfy the interoperability desired by Dune::EntityPointer. Of course, this trick has some consequences:
>> (a) There is no guarantee that the code will work
>>  (but that holds for the cast in Dune::EntityPointer as well).
>> (b) The last member of your entity pointer must be the host iterator
>>  (which is the one actually casted by the reinterpret_cast).
>> Apart from that, the code seems to work wonderfully. I have to admit, though, that I never use the deprecated cast operator in my code.
> 
> That's what I do as well. The problem occured while I was trying to debug a problem where the compiler picked a wrong constructor
> and wanted to make sure that the constructor argument would not be casted using the reference cast operator.
> 
> Steffen
> 
>> 
>> Best,
>> 
>> Martin
>> 
>> 
>> -- 
>> Dr. Martin Nolte <nolte at mathematik.uni-freiburg.de>
>> 
>> Universität Freiburg                                   phone: +49-761-203-5630
>> Abteilung für angewandte Mathematik                    fax:   +49-761-203-5632
>> Hermann-Herder-Straße 10
>> 79104 Freiburg, Germany
> 
> Steffen Müthing
> Universität Stuttgart
> Institut für Parallele und Verteilte Systeme
> Universitätsstr. 38
> 70569 Stuttgart
> Tel: +49 711 685 88429
> Fax: +49 711 685 88340
> Email: steffen.muething at ipvs.uni-stuttgart.de_______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune

Steffen Müthing
Universität Stuttgart
Institut für Parallele und Verteilte Systeme
Universitätsstr. 38
70569 Stuttgart
Tel: +49 711 685 88429
Fax: +49 711 685 88340
Email: steffen.muething at ipvs.uni-stuttgart.de





-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 495 bytes
Desc: Signierter Teil der Nachricht
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20120427/cc72e27c/attachment.sig>


More information about the Dune mailing list