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
ITK was recently changed from using 'ato[ifd]' to using 'sto[ifd]' in an attempt to provide more robust error checking.
commit b9a384af33e904ae0da212ace9130632c808c6fd
Author: Hans Johnson <[email protected]>
Date: Sat Sep 22 12:57:23 2018
STYLE: Prefer error checked std::stoi over atoi
The atoi function does not provide mechanisms for distinguishing between
'0' and the error condion where the input can not be converted.
std::stoi provides exception handling and detects when an invalid
string attempts to be converted to an integer.
atoi()
Con: No error handling.
Con: Handle neither hexadecimal nor octal.
The use of atoi in code can cause it to be subtly broken.
atoi makes two very big assumptions indeed:
The string represents an integer/floating point value.
The integer can fit into an int.
Impact analysis
The above change now introduces a data dependant throw of low-level C++ exceptions. ITK should convert these into ITK exceptions instead, with non-generic messages based on the situation.
Expected behavior
ITK generates context-specific ITK exceptions in data-induced exceptions.
Actual behavior
Default low level c++ exeptions are thrown of type
If no conversion could be performed, an [invalid_argument](https://www.cplusplus.com/invalid_argument) exception is thrown.
If the value read is out of the range of representable values by an int, an [out_of_range](https://www.cplusplus.com/out_of_range) exception is thrown.
Description
ITK was recently changed from using 'ato[ifd]' to using 'sto[ifd]' in an attempt to provide more robust error checking.
Impact analysis
The above change now introduces a data dependant throw of low-level C++ exceptions. ITK should convert these into ITK exceptions instead, with non-generic messages based on the situation.
Expected behavior
ITK generates context-specific ITK exceptions in data-induced exceptions.
Actual behavior
Default low level c++ exeptions are thrown of type
Versions
All TIK versions after commit b9a384a
Additional Information
This change was discussed in the context of : Slicer/Slicer#6200
The text was updated successfully, but these errors were encountered: