[Dune] Exception specifier for *operator new in debugallocator

Christian Engwer christian.engwer at uni-muenster.de
Wed Oct 10 09:35:08 CEST 2012


On Wed, Oct 10, 2012 at 07:59:06AM +0200, Christoph Grüninger wrote:
> Good morning Dune, hi Christian,
> while doing "make check" I got an error stating "declaration [..]
> has a different exception specifier" in debugallocator.hh. Do the
> implementations differ? Or may I apply the attached patch, which

You should not. Please file a bug-report. It seems we are facing
(again) some incompatibilities between C++03 and C++11.

According to C++03 3.7.3 "Dynamic storage duration":

  The following allocation and deallocation functions
  (18.4) are implicitly declared in global scope in each translation
  unit of a program
    void* operator new(std::size_t) throw(std::bad_alloc);
    void* operator new[](std::size_t) throw(std::bad_alloc);
    void operator delete(void*) throw();
    void operator delete[](void*) throw();

whereas C++11 3.7.4 "Dynamic storage duration" states:

  Any such function definition replaces the default version provided
  in the library (17.6.4.6). The following allocation and deallocation
  functions (18.6) are implicitly declared in global scope in each
  translation unit of a program.
    void* operator new(std::size_t);
    void* operator new[](std::size_t);
    void operator delete(void*);
    void operator delete[](void*);

Christian

> solves the issue for me. Thou I suspect it will break the code for
> other compilers...
> 
> Bye
> Christoph
> 
> 
> The error message:
> 
> >In file included from testdebugallocator.cc:8:0:
> >../../../dune/common/debugallocator.hh: In function ‘void* operator new(size_t)’:
> >../../../dune/common/debugallocator.hh:288:54: error: declaration of ‘void* operator new(size_t) throw (std::bad_alloc)’ has a different exception specifier
> >In file included from /usr/include/c++/4.7/ext/new_allocator.h:34:0,
> >                 from /usr/include/c++/4.7/x86_64-suse-linux/bits/c++allocator.h:34,
> >                 from /usr/include/c++/4.7/bits/allocator.h:48,
> >                 from /usr/include/c++/4.7/vector:62,
> >                 from ../../../dune/common/debugallocator.hh:6,
> >                 from testdebugallocator.cc:8:
> >/usr/include/c++/4.7/new:93:7: error: from previous declaration ‘void* operator new(std::size_t)’
> 
> The patch:
> 
> Index: dune/common/debugallocator.hh
> ===================================================================
> --- dune/common/debugallocator.hh       (revision 7033)
> +++ dune/common/debugallocator.hh       (working copy)
> @@ -285,7 +285,7 @@
>  }
> 
>  #ifdef DEBUG_NEW_DELETE
> -void * operator new(size_t size) throw(std::bad_alloc)
> +void * operator new(size_t size)
>  {
>      // try to allocate size bytes
>      void *p = Dune::DebugMemory::alloc_man.allocate<char>(size);
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune

-- 
Prof. Dr. Christian Engwer 
Institut für Numerische und Angewandte Mathematik
Fachbereich Mathematik und Informatik der Universität Münster
Einsteinstrasse 62
48149 Münster

E-Mail	christian.engwer at uni-muenster.de
Telefon	+49 251 83-35067
FAX		+49 251 83-32729




More information about the Dune mailing list