Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add exception specification for xbt_free_f.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 6 Mar 2019 20:49:49 +0000 (21:49 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 6 Mar 2019 20:49:52 +0000 (21:49 +0100)
Take the same exception specification as for std::free. Without that, Intel icc
fails to compile simgrid::xbt::demangle (backtrace.cpp) with:
error \#878: incompatible exception specifications

include/xbt/sysdep.h
src/xbt/xbt_main.cpp

index 93b5e62..7cdf659 100644 (file)
@@ -110,10 +110,16 @@ static XBT_ALWAYS_INLINE void *xbt_realloc(void *p, size_t s) {
     @hideinitializer */
 #define xbt_free(p) free(p) /*nothing specific to do here. A poor valgrind replacement? */
 
+#ifdef __cplusplus
+#define XBT_FREE_NOEXCEPT noexcept(noexcept(std::free))
+#else
+#define XBT_FREE_NOEXCEPT
+#endif
+
 /** @brief like free, but you can be sure that it is a function  */
-XBT_PUBLIC void xbt_free_f(void* p);
+XBT_PUBLIC void xbt_free_f(void* p) XBT_FREE_NOEXCEPT;
 /** @brief should be given a pointer to pointer, and frees the second one */
-XBT_PUBLIC void xbt_free_ref(void* d);
+XBT_PUBLIC void xbt_free_ref(void* d) XBT_FREE_NOEXCEPT;
 
 SG_END_DECL()
 
index 826489a..4129fc1 100644 (file)
@@ -135,13 +135,13 @@ void xbt_init(int *argc, char **argv)
 
 /* these two functions belong to xbt/sysdep.h, which have no corresponding .c file */
 /** @brief like xbt_free, but you can be sure that it is a function  */
-void xbt_free_f(void *p)
+void xbt_free_f(void* p) noexcept(noexcept(std::free))
 {
   xbt_free(p);
 }
 
 /** @brief should be given a pointer to pointer, and frees the second one */
-void xbt_free_ref(void *d)
+void xbt_free_ref(void* d) noexcept(noexcept(std::free))
 {
   xbt_free(*(void**)d);
 }