From: Frederic Suter Date: Thu, 18 May 2017 16:04:26 +0000 (+0200) Subject: attempt to get rid of all const_cast (take 2) X-Git-Tag: v3.16~281^2~12 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/377d2091c1e0f30ef48fb068f672ae624ad59d0f attempt to get rid of all const_cast (take 2) --- diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index 2c7c87d231..10c16bf98a 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -39,11 +39,12 @@ public: {} void operator()() const { + char noarg[] = {'\0'}; const int argc = args_->size(); std::vector args = *args_; std::unique_ptr argv(new char*[argc + 1]); for (int i = 0; i != argc; ++i) - argv[i] = args[i].empty() ? '\0' : &args[i].front(); + argv[i] = args[i].empty() ? noarg : &args[i].front(); argv[argc] = nullptr; code_(argc, argv.get()); } diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 63f2a6cdbe..ff2da6f47d 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -489,10 +489,11 @@ typedef void (*smpi_fortran_entry_point_type)(); static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector args) { + char noarg[] = {'\0'}; const int argc = args.size(); std::unique_ptr argv(new char*[argc + 1]); for (int i = 0; i != argc; ++i) - argv[i] = args[i].empty() ? '\0' : &args[i].front(); + argv[i] = args[i].empty() ? noarg : &args[i].front(); argv[argc] = nullptr; int res = entry_point(argc, argv.get());