-
Notifications
You must be signed in to change notification settings - Fork 404
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
'convert' is broken for edge cases #2055
Comments
@Dennis40816 The question is whether to only fix this issue or to overhaul the whole conversion class since it still converts to |
Oh, and be warned, this can be a sisyphean task to get everything right :) |
@elBoberido, as you've suggested, let's prioritize fixing the The current
Discussion:
|
I hope one day we can completely fix this :( |
I think it would a good idea to add When it comes to the We are also free to change the API to our likes. Currently we only support base 10 but it would be quite simple to support base 16 by adding another parameter. This could be done in a follow up with a default value of 10. The class also predates the introduction of the Furthermore, we introduced What are your thoughts? |
Oh, before you start. We decided to move the classes from |
Yes, I agree we can add
I believe that you are correct. Similar issue for
Sure.
Ok, let's implement
Not sure it's correct or not but I think |
|
Oh, regarding this issue. I think we can get rid of We can just rely on the actual C function to tell us that a conversion failed. This should simplify the code a bit and also make it more performant. |
Okay, convert is back in iceoryx_hoofs. You can now start whenever you like without having to do additional work :) |
Thanks for your knowledge :) All right. I create a todo list here to remind myself. If anything miss, feel free to leave a comment. First step
Second step
|
For the PR, I think I'll be quite busy within following two weeks. I'll try my best to create one. |
I'm not quite sure what you mean by The plan looks good. Go ahead.
Don't worry. Start whenever you have time. There is no pressure in getting this done anytime soon. As long as you have fun contributing to the project we are happy too :) |
Rename `fromString` to `from_string`. Note that the name of test cases are not included. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Remove dest for numeric conversion. Now, the part of `for_string` will return iox::optional. Also, we introduce `validate_return_value` and `check_edge_case` to simplify the code of checking. The former can be used to return an iox::optional object while the latter is used in the former to check whether any conversion failure happened. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
- only MSVC will treat subnormal as valid input. Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Signed-off-by: Dennis Liu <[email protected]>
Required information
Operating system:
all
Compiler version:
all
Eclipse iceoryx version:
all
Observed result or behaviour:
Conversions from strings like
nan
,inf
orDBL_MAX
for floating point types orULLONG_MAX
for uint64_t fail.Expected result or behaviour:
All valid values should be converted.
Conditions where it occurred / Performed steps:
Try to convert
inf
todouble
or18446744073709551615
touint64_t
Detailed description of the problem
The conversion functions have some weird way to tell the user something went wrong. Let's take
strtoull
for exampleThere are three scenarios:
nptr == endptr
, the conversion failed because there were no valid charactersnptr != endptr && *endptr != '\0'
, the conversion was (probably) successful and it depends on the user if this is correct because not all characters were converted, e.g. if the user is passed123ab
then*endptr
would bea
but if the user expected the whole string to be a number, this should be an errornptr != endptr && *endptr != '\0'
, the conversion was (probably) successful2 and 3 might still have failed if the return value was
ULLONG_MAX
and theerrno
is set toERANGE
.All of this has to be taken care of or the conversion will fail on edge cases
Test program
This small test program can be used to observe the behavior for string to integer and string to floating point conversion.
Tasks
The text was updated successfully, but these errors were encountered: