Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect integer conversion #38

Open
rip-nsk opened this issue Nov 27, 2023 · 0 comments
Open

incorrect integer conversion #38

rip-nsk opened this issue Nov 27, 2023 · 0 comments

Comments

@rip-nsk
Copy link

rip-nsk commented Nov 27, 2023

pattern is

    T ret = static_cast<T>(std::strtoX(arg, &endptr, 0));
    if (endptr == arg) {
      throw std::invalid_argument(msg.str());
    }

issues:

  • static_cast hides target value overflow if T shorter than long
  • unsigned values greater than signed.max() result in ERANGE
  • unparsed suffix ignored - "10x" considered as "10"
  • throw std::invalid_argument is actually ignored, because
    try {
      return convert::arg<T>(this->arg);
    } catch (...) {
      return t;
    }

@rip-nsk rip-nsk changed the title incorrect integral conversion incorrect integer conversion Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant