From e94d23a9338ae2aab92cf1304dc19494780778b3 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 6 Mar 2019 21:49:49 +0100 Subject: [PATCH 1/1] Add exception specification for xbt_free_f. 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 | 10 ++++++++-- src/xbt/xbt_main.cpp | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/xbt/sysdep.h b/include/xbt/sysdep.h index 93b5e62529..7cdf659412 100644 --- a/include/xbt/sysdep.h +++ b/include/xbt/sysdep.h @@ -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() diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 826489ac42..4129fc1846 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -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); } -- 2.20.1