Skip to content

Float parsing sometimes fails when given too many repeating digits #41317

@df5602

Description

@df5602

While fuzzing a toy parser, I stumbled upon a few seemingly valid float literals, where f64::from_str() returned an Error. The floats that trigger this behaviour have a lot (~200) of repeating digits.

See example in Rust playground:
https://play.rust-lang.org/?gist=93f8ae91e66c6b78814b397429b189b1&version=stable&backtrace=0

Other float literals that cannot be parsed correctly:
6666666.6666666667666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666766666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666,
666666666666666666666666666.66666666676666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666,
6666666666666666676666666666666666666666666666666666666666666666666666666617666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666.66666666666666666666666666666666666666666666666666666666666666666666667666666666666666666666666666666666666666666,
etc.

The fuzzer ran with rustc 1.11.0-nightly (01411937f 2016-07-01), but the issue can also be reproduced in current stable and nigthly versions of Rust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions