[Dune] Weird behaviour of MPIHelper

Martin Nolte nolte at mathematik.uni-freiburg.de
Tue May 19 15:45:57 CEST 2015


Hi Aleksejs

you're returning a reference to a temporary, so weird behaviour is normal. To my 
knowledge, however, the compiler should emit a warning in this case. Did you 
disable / ignore them by accident?

Best,

Martin

On 05/19/2015 03:28 PM, Aleksejs Fomins wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dear Dune,
>
> I am having trouble with very basic c++ pointer problem in my curvilinear grid. The file grid.hh contains 2 functions:
>
>      const CollectiveCommunication &comm () const  { return mpihelper_.getCollectiveCommunication(); }
>
>      MPIHelper & mpihelper()  const { return mpihelper_; }
>
> One of them returns the MPIHelper reference, the other the CollectiveCommunication reference.
>
>
> I write a test program:
>
> Grid * grid = factory.createGrid();
>
> std::cout << "rank v1 = " << grid->comm().rank() << std::endl;
> std::cout << "rank v2 = " << grid->mpihelper().getCollectiveCommunication().rank() << std::endl;
>
> the result for a serial run is
> - -1183734688
> 0
>
> And the first result puzzles me a lot, as I expect it to be equal to the 2nd one. Otherwise, the grid is functioning well, so it is definitely initialized
>
> Any ideas?
>
> Greetings,
> Aleksejs
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
>
> iQIcBAEBAgAGBQJVWzqSAAoJEDkNM7UOEwMZgxEP/iL0mj7E/os0cqxgPKNH3Pg7
> BdenRCd+j4ZhcMGQVGPZo3qRcFnJq0cOX1nvjyHBuLPV6pv6dqWQIoG1I5EQhDMQ
> meo9534vf/Mk2t8bwpJ4DkBfC9xWcwStjB8BrpK+BTrtmm3kgqpum7sNoDe5g3NW
> 11Ioayg97j/fkAfakhk2VbaCWWeVelOVzIVOle2OOBXfvTsLIzdXYIzDuRWTJKSR
> cJ53LLyOiQxsm6McGTwX+bie2H6Cl2SKB5twy7GCcOvFV8yu+KbuNzeS7Huqjsyc
> biwJuyeS74hCD3PCeFmWlwb4R63epBrXv9TMK/qRNY0fT7gBpJAUkEkRS9Ohn/6t
> ExJh295XZkRor6554MvoYn2S0RQ+5ATxaGCQqB4Rxqpfx1Ig3kuJdT4BCajfQ9wI
> tZZkIA+6rYn5gkgGDX9PpQETZwIK3aQydJPBib237KAcRHDEzlwkCcL5LARCXUlX
> yMzFHuAIEXraXKRHH/z6Ku2TamJGl/Liv6AvVJ8n0br8KHZny5VPZNB1a0T+rcfh
> gtW/RJ2yfDY0FpBLldR5DrvfNZeTBqaFCJ2XHCY3jNeHpTAxAlMNTza/JZIh7umM
> PfHK+Pwr81JBcBsG8HiRba0aIoXHQ6L/x0GOag5sUpd8iBo1o6iJ4Tv415ib43It
> VPlbTFJ3YoPYhemMEZZR
> =1Yms
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
>

-- 
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




More information about the Dune mailing list