xref: /OK3568_Linux_fs/buildroot/package/duma/0003-fix-C++14.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1dumapp: fix for C++14
2
3With C++14, the way exceptions are specified has changed (somehow, don't
4ask me), thus causing build failures:
5
6    dumapp.cpp: In function ‘void* operator new(std::size_t)’:
7    dumapp.cpp:192:19: error: declaration of ‘void* operator new(std::size_t) throw (std::bad_alloc)’ has a different exception specifier
8     void * DUMA_CDECL operator new( DUMA_SIZE_T size )
9                       ^~~~~~~~
10    In file included from dumapp.cpp:39:0:
11    dumapp.h:91:23: note: from previous declaration ‘void* operator new(std::size_t)’
12     void * DUMA_CDECL operator new(DUMA_SIZE_T) throw(std::bad_alloc);
13                       ^~~~~~~~
14
15This is most evident with gcc-6.x, since the default C++ standard has
16changed from C++11 to C++14, thus exposing these new failures.
17
18Fix that by guarding the exception handling, a bit like was done
19with GRASS GIS (thanks DuckDuckGo):
20
21    https://trac.osgeo.org/grass/changeset?old_path=%2F&old=68817&new_path=%2F&new=68818&sfp_email=&sfph_mail=
22
23Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
24
25---
26Note: The last commit in DUMA's CVS repo was more than 7 years ago.
27I doubt it is still active, so the patch was not sent upstream. :-/
28
29diff -durN duma-2.5.15.orig/dumapp.cpp duma-2.5.15/dumapp.cpp
30--- duma-2.5.15.orig/dumapp.cpp	2008-08-03 22:46:06.000000000 +0200
31+++ duma-2.5.15/dumapp.cpp	2016-07-10 21:55:22.670386099 +0200
32@@ -190,7 +190,9 @@
33  * (11) = (a) ; ASW
34  */
35 void * DUMA_CDECL operator new( DUMA_SIZE_T size )
36+#ifdef DUMA_EXCEPTION_SPECS
37 throw(std::bad_alloc)
38+#endif
39 {
40   return duma_new_operator(size, EFA_NEW_ELEM, true  DUMA_PARAMS_UK);
41 }
42@@ -254,7 +256,9 @@
43  * (21) = (a) ; AAW
44  */
45 void * DUMA_CDECL operator new[]( DUMA_SIZE_T size )
46+#ifdef DUMA_EXCEPTION_SPECS
47 throw(std::bad_alloc)
48+#endif
49 {
50   return duma_new_operator(size, EFA_NEW_ARRAY, true  DUMA_PARAMS_UK);
51 }
52diff -durN duma-2.5.15.orig/dumapp.h duma-2.5.15/dumapp.h
53--- duma-2.5.15.orig/dumapp.h	2009-04-11 14:41:44.000000000 +0200
54+++ duma-2.5.15/dumapp.h	2016-07-10 21:55:22.670386099 +0200
55@@ -35,6 +35,10 @@
56
57 #include "duma.h"
58
59+#if __cplusplus < 201103L
60+  #define DUMA_EXCEPTION_SPECS 1
61+#endif
62+
63 /* remove previous macro definitions */
64 #include "noduma.h"
65
66