[Dune] Possible error in "poolallocator.hh"

Bård Skaflestad Bard.Skaflestad at sintef.no
Thu Apr 3 17:04:37 CEST 2014


All,

I recently switched to basing a project on the Dune 2.3.0 release sources (modules -common, -geometry, -grid, and -istl), downloaded as tar-balls from dune-project.org.  When dialing up the diagnostics I suddenly started to get linker errors in code I did not write myself and which built fine against the Dune 2.2.1 release.  I'm certainly not excluding errors in my own code, but I am soliciting opinions on one possible issue in dune-common's "PoolAllocator" class (cf., dune/common/poolallocator.hh).

The Dune::PoolAllocator<T,size> contains a (private) Dune::Pool<T,size> member, memoryPool_ .  Class Dune::Pool<T,size> is explicitly not copyable because it contains a privately declared and unimplemented copy constructor.  In the 2.2.1 release, the "memoryPool_" was a *class* member (i.e., declared "static") but in the interest of thread support it was made into an instance member in (dune-common) commit f78ce3a8db which is part of the 2.3.0 release.  Now, although the PoolAllocator<> contains

    template<typename U, std::size_t u>
    PoolAllocator(const PoolAllocator<U,u>&)
    {}

this does not qualify as a copy constructor (if I understand correctly, those cannot be templates), so the PoolAllocator<> gets the standard, compiler-generated copy constructor which "simply" invokes the copy constructor for all instance members.  As the Pool<> is non-copyable, this leads to linker errors of the form

    undefined reference to `Pool::Pool(const Pool&)'

I do admit that I was quite surprised that I didn't experience the problem until I started to increase the diagnostic level of the build. I suspect, but haven't verified, that it was using libstdc++'s "debug" mode through compiler switches -D_GLIBCCX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1 that brought the issue to the fore.  However, the PoolAllocator is unfamiliar code so I could well be missing something obvious.  Hence this question.

In the meantime, explicitly declaring (and implementing) a PoolAllocator<> copy constructor as

    PoolAllocator(const PoolAllocator&)
    { /* No-op */ }

allows the debug build of my project to finish.

Comments most welcome.  What am I missing?


Sincerely,
-- 
Bård Skaflestad <Bard.Skaflestad at sintef.no>
SINTEF ICT, Applied Mathematics



More information about the Dune mailing list