X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6c7b494f8d1203fb34e01e349b339a70a68daa7a..a27340a44ca0010cef5e5134627dd7774cc911c3:/src/xbt/config.cpp diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index 5a9cb8d74a..ef9fcf678a 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -99,7 +99,12 @@ public: static constexpr const char* type_name = "int"; static inline int parse(const char* value) { - return parse_long(value); + long val = parse_long(value); + if (val < INT_MIN) + throw std::range_error("underflow"); + if (val > INT_MAX) + throw std::range_error("overflow"); + return static_cast(val); } }; template <> class ConfigType { @@ -260,7 +265,7 @@ public: { xbt_assert(options.find(name) == options.end(), "Refusing to register the config element '%s' twice.", name.c_str()); - TypedConfigurationElement* variable = new TypedConfigurationElement(name, std::forward(a)...); + auto* variable = new TypedConfigurationElement(name, std::forward(a)...); XBT_DEBUG("Register cfg elm %s (%s) of type %s @%p in set %p)", name.c_str(), variable->get_description().c_str(), variable->get_type_name(), variable, this); options[name].reset(variable);