https://bugs.kde.org/show_bug.cgi?id=415537

--- Comment #2 from Matt Whitlock <k...@mattwhitlock.name> ---
Analogous concerns apply for switch-statement with initializer.


/* BEGIN example2.cpp */

#include <charconv>
#include <limits>
#include <system_error>

unsigned parse_uint_clamp(const char *begin, const char *end) {
  unsigned v;
  switch (auto [ptr, ec] = std::from_chars(begin, end, v); ec) {  // broken
    case std::errc { }:
      if (ptr != end) {  // broken
        return 0;
      }
      return v;
    case std::errc::result_out_of_range:
      return std::numeric_limits<unsigned>::max();
    default:
      throw std::system_error(std::make_error_code(ec));  // broken
  }
}

/* END example2.cpp */

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to