mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 14:44:40 +00:00
do_from_chars(): initialize variable to fix Coverity Scan warning
The argparse.hpp copy inside GDAL has caused Coverity Scan to emit a (false-positive) warning about x not being initialized. ``` ________________________________________________________________________________________________________ *** CID 1544814: Uninitialized variables (UNINIT) /gdal/apps/argparse/argparse.hpp: 257 in gdal_argparse::details::do_from_chars<unsigned char, (int)10>(std::basic_string_view<char, std::char_traits<char>>)() 251 if (ec == std::errc::invalid_argument) { 252 throw std::invalid_argument{"pattern '" + std::string(s) + "' not found"}; 253 } 254 if (ec == std::errc::result_out_of_range) { 255 throw std::range_error{"'" + std::string(s) + "' not representable"}; 256 } >>> CID 1544814: Uninitialized variables (UNINIT) >>> Using uninitialized value "x". ``` Let's initialize it to 0 to make the analyzer happy
This commit is contained in:
parent
ce7db9962a
commit
5228c57938
@ -238,7 +238,7 @@ constexpr auto consume_hex_prefix(std::string_view s)
|
|||||||
|
|
||||||
template <class T, auto Param>
|
template <class T, auto Param>
|
||||||
inline auto do_from_chars(std::string_view s) -> T {
|
inline auto do_from_chars(std::string_view s) -> T {
|
||||||
T x;
|
T x{0};
|
||||||
auto [first, last] = pointer_range(s);
|
auto [first, last] = pointer_range(s);
|
||||||
auto [ptr, ec] = std::from_chars(first, last, x, Param);
|
auto [ptr, ec] = std::from_chars(first, last, x, Param);
|
||||||
if (ec == std::errc()) {
|
if (ec == std::errc()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user