[RFC] do_get of floats vs underflow
Benjamin Kosnik
bkoz@redhat.com
Fri Apr 6 16:23:00 GMT 2007
> Since, according to the standard, the behavior of num_get is "as-if"
> scanf, not "as-if" strtof, and scanf certainly doesn't fail in any sense
> in case of floating point underflow (at least this is what I'm seeing on
> linux), I would guess we could just avoid checking whether errno ==
> ERANGE, don't fiddle at all with errno, and instead just check that the
> value returned by strtof is != HUGE_VAL && != -HUGE_VAL.
Indeed.
> Or dot we have reasons to believe people are relying (uncorrectly) on
> failbit being set in case of underflow? When evaluating this issue, we
> should also consider that, according to C99, 7.20.1.3/10, about strtof &
> co, in case of underflow "whether errno acquires the value ERANGE is is
> implementation-defined". Thus, I would say I do not consider the latter
> expectation very reasonable, in general.
Yes, I think your analysis is sound. Your follow-up patch looks good to me.
best,
benjamin
More information about the Libstdc++
mailing list