https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83676
Bug ID: 83676
Summary: Problems with sscanf parsing hex-floats
Product: gcc
Version: 7.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: BM-2cUWXLL9JqDWpsk8EivFHCgbsbXFtsxQrk at bitmessage dot ch
Target Milestone: ---
Created attachment 43023
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43023&action=edit
example code, visualizing the behavior from above
Assume `d` as a normal double variable.
Executing
`sscanf ( "0x", "%lf", &d )`
returns `0` and `d` isn't modified, 'cause the string can't be parsed.
I think that 0x indicates in correspondence with `%lf`, that there seem to be a
maybe slightly incomplete hex-float.
But wouldn't it be a better behavior if this statement is correctly parsed into
the double `d` with the value `0`, 'cause ignoring the `x` and correctly
parsing `0` as well as assuming that `0x` originally means `0x0` is a much more
thought-out behavior than just saying "sry, but this can't be parsed, so it's
better doing nothing"?
Even though `sscanf ( "0x", "%i", &i )` returns successfully `1` and the
integer value `i` is going to have the value `0`. Furthermore e.g. BSD'
versions of GCC correctly parses the 0x-lf case...
I'm using a x86_64-pc-linux-gnu 4.14.9-Linux to compile the code without any
significant options (no compiler warnings present).
Thanks!