Fix warning: maybe-uninitialized

../../components/misc/color.cpp: In static member function 'static Misc::Color Misc::Color::fromHex(std::string_view)':
../../components/misc/color.cpp:36:24: error: 'v' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   36 |             rgb[i] = v / 255.0f;
      |                      ~~^~~~~~~~
C++20
elsid 3 years ago
parent 70623d0b23
commit b0f192d878
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -29,7 +29,7 @@ namespace Misc
for (size_t i = 0; i < rgb.size(); i++)
{
auto sub = hex.substr(i * 2, 2);
int v;
int v = 0;
auto [_, ec] = std::from_chars(sub.data(), sub.data() + sub.size(), v, 16);
if (ec != std::errc())
throw std::logic_error(std::string("Invalid hex color: ") += hex);

Loading…
Cancel
Save