You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since we do not use the 'pos' parameter of stoi/stol/stoll/stoul/stoull/stof/stod/stold, many parameters allow garbage after the number.
For example, I accidentally passed -t 24,3.9 (meaning to use llama.cpp's '-ts' option), and this was interpreted as simply '24' with no error. Also, all of the integer options accept floating-point arguments, but silently alter them, e.g. '1e5' and '1.5' are both interpreted as '1'.
A correct use of stoi to parse a single number looks more like this:
size_t pos;
auto i = std::stoi(s, &pos);
if (pos < s.size())
throwstd::invalid_argument(s);
Although it would be even better if we avoided unhandled exceptions for parsing errors, so we do not coredump in such cases. Printing an error message and then calling exit(1) would be better.
The text was updated successfully, but these errors were encountered:
Since we do not use the 'pos' parameter of stoi/stol/stoll/stoul/stoull/stof/stod/stold, many parameters allow garbage after the number.
For example, I accidentally passed
-t 24,3.9
(meaning to use llama.cpp's '-ts' option), and this was interpreted as simply '24' with no error. Also, all of the integer options accept floating-point arguments, but silently alter them, e.g. '1e5' and '1.5' are both interpreted as '1'.A correct use of stoi to parse a single number looks more like this:
Although it would be even better if we avoided unhandled exceptions for parsing errors, so we do not coredump in such cases. Printing an error message and then calling
exit(1)
would be better.The text was updated successfully, but these errors were encountered: