[Dune] Exception specifier for *operator new in debugallocator

Steffen Müthing steffen.muething at ipvs.uni-stuttgart.de
Wed Oct 10 10:21:04 CEST 2012


Am 10.10.2012 um 09:35 schrieb Christian Engwer:

> 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*);

That's a consequence of deprecating dynamic exception specifications.
The new standard provides a more limited replacement with the noexcept
keyword. That one could have been applied to operator delete(), but the
committee obviously didn't think that was worth the bother…

Steffen

> 
> 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
> 
> _______________________________________________
> 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: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20121010/bd5bb446/attachment.sig>


More information about the Dune mailing list