From: Arnaud Giersch Date: Thu, 29 Sep 2022 15:29:41 +0000 (+0200) Subject: Use std::fill instead of memset. X-Git-Tag: v3.32~13 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9992c04bba629eccd44905b4db102436727a779d Use std::fill instead of memset. It's a bit more C++'ish, and it seems to help to workaround what looks like an optimization bug in IntelLLVM 2022.2.0 (xbt::dict unit tests are failing). --- diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index 280d047537..6573bb88ed 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -15,6 +15,7 @@ #include "xbt/string.hpp" #include "xbt/xbt_modinter.h" +#include #include #include @@ -90,7 +91,7 @@ static void xbt_dict_rehash(xbt_dict_t dict) unsigned newsize = oldsize * 2; auto* newtable = static_cast(xbt_realloc(dict->table, newsize * sizeof(xbt_dictelm_t))); - memset(&newtable[oldsize], 0, oldsize * sizeof(xbt_dictelm_t)); /* zero second half */ + std::fill(newtable + oldsize, newtable + newsize, nullptr); /* zero second half */ newsize--; dict->table_size = newsize; dict->table = newtable;