[GRASS-SVN] r68912 - in grass/branches/releasebranch_7_0: include/iostream lib/iostream

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 9 12:05:28 PDT 2016


Author: wenzeslaus
Date: 2016-07-09 12:05:28 -0700 (Sat, 09 Jul 2016)
New Revision: 68912

Modified:
   grass/branches/releasebranch_7_0/include/iostream/mm.h
   grass/branches/releasebranch_7_0/lib/iostream/mm.cpp
Log:
use exception specifiers only for C++ versions older than C++11 (backport r68818, closes #2871, see #2956)

Modified: grass/branches/releasebranch_7_0/include/iostream/mm.h
===================================================================
--- grass/branches/releasebranch_7_0/include/iostream/mm.h	2016-07-09 18:59:49 UTC (rev 68911)
+++ grass/branches/releasebranch_7_0/include/iostream/mm.h	2016-07-09 19:05:28 UTC (rev 68912)
@@ -39,6 +39,11 @@
 
 #include <sys/types.h>
 
+// GCC with C++98 and -fexceptions requires exception
+// specifiers, however with C++11 and newer, using them causes an error.
+#if __cplusplus < 201103L
+#define GRASS_MM_USE_EXCEPTION_SPECIFIER
+#endif /* __cplusplus < 201103L */
 
 #define MM_REGISTER_VERSION 2
 
@@ -128,10 +133,17 @@
   void print();
 
   friend class mm_register_init;
-  friend void * operator new(size_t) throw(std::bad_alloc);
-  friend void * operator new[](size_t) throw(std::bad_alloc);
+#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
+  friend void * operator new(size_t) throw (std::bad_alloc);
+  friend void * operator new[] (size_t) throw (std::bad_alloc);
   friend void operator delete(void *) throw();
   friend void operator delete[](void *) throw();
+#else
+  friend void * operator new(size_t);
+  friend void * operator new[] (size_t);
+  friend void operator delete(void *) noexcept;
+  friend void operator delete[](void *) noexcept;
+#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
 };
 
 

Modified: grass/branches/releasebranch_7_0/lib/iostream/mm.cpp
===================================================================
--- grass/branches/releasebranch_7_0/lib/iostream/mm.cpp	2016-07-09 18:59:49 UTC (rev 68911)
+++ grass/branches/releasebranch_7_0/lib/iostream/mm.cpp	2016-07-09 19:05:28 UTC (rev 68912)
@@ -276,7 +276,11 @@
 
  
 /* ************************************************************ */
-void* operator new[] (size_t sz) throw(std::bad_alloc) {
+#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
+void* operator new[] (size_t sz) throw (std::bad_alloc) {
+#else
+void* operator new[] (size_t sz) {
+#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
   void *p;
   
   MM_DEBUG cout << "new: sz=" << sz << ", register " 
@@ -327,7 +331,11 @@
 
  
 /* ************************************************************ */
-void* operator new (size_t sz) throw(std::bad_alloc) {
+#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
+void* operator new (size_t sz) throw (std::bad_alloc) {
+#else
+void* operator new (size_t sz) {
+#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
   void *p;
   
   MM_DEBUG cout << "new: sz=" << sz << ", register " 
@@ -379,7 +387,11 @@
 
 
 /* ---------------------------------------------------------------------- */
+#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
 void operator delete (void *ptr) throw() {
+#else
+void operator delete (void *ptr) noexcept {
+#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
   size_t sz;
   void *p;
   
@@ -419,7 +431,11 @@
 
 
 /* ---------------------------------------------------------------------- */
+#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
 void operator delete[] (void *ptr) throw() {
+#else
+void operator delete[] (void *ptr) noexcept {
+#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
   size_t sz;
   void *p;
   



More information about the grass-commit mailing list