[Dune] 'auto&&' or 'const auto&' ?

Steffen Müthing steffen.muething at iwr.uni-heidelberg.de
Mon Oct 12 16:22:57 CEST 2015


Hi Bernd,

> Am 12.10.2015 um 15:50 schrieb Bernd Flemisch <bernd at iws.uni-stuttgart.de>:
> 
> Dear Dune,
> 
> should I use 'auto&&' or 'const auto&' in a range-based for-loop over the entities of a Dune GridView?
> 
> On the one hand, there is
> https://www.dune-project.org/doc/doxygen/html/group__GIIteration.html#_details
> which says "**always** use 'auto&&'"
> 
> On the other hand, there is
> http://conan2.iwr.uni-heidelberg.de/git/pdelab/dune-pdelab/commit/d97c563807cd4f9aaa872dfee57c668eda12db59
> together with
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63506
> which indicates that a GCC bug is triggered when using 'auto&&‘.

yes, it’s all quite a mess: Basically, the standard (and important people like Stroustrup and Sutter) say that you
should *always* use auto&& in a range-based for loop, but GCC has this bug that sometimes causes a compilation
failure if the range-based for appears inside a function template, so you have to use const auto&.

So, the (rather unfortunate) advice is: You should use auto&&, but you can’t if you target current GCC due to a bug in
GCC. In that case, you have to use const auto&.

We should probably update the Doxygen documentation to explain the issue (I forgot about that when I discovered the compiler
b) because we’ll be stuck with the problem for the foreseeable future - the bug is still present in the GCC 6 snapshot from
the beginning of September that I have available on my machine, and the GCC Bugzilla bug hasn’t seen any attention in a long
time. Apart from that, the bug is in GCC 5, which we will have to support for a few years to come…

So I think the documentation needs to explain this issue.

Steffen

> 
> Kind regards
> Bernd
> 
> --
> _______________________________________________________________
> 
> Bernd Flemisch                         phone: +49 711 685 69162
> IWS, Universität Stuttgart             fax:   +49 711 685 60430
> Pfaffenwaldring 61            email:bernd at iws.uni-stuttgart.de
> D-70569 Stuttgart            url:www.hydrosys.uni-stuttgart.de
> _______________________________________________________________
> 
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20151012/10c6e53a/attachment.sig>


More information about the Dune mailing list