JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.55k stars 5.47k forks source link

Difference in Float32 parsing on Windows and Linux #55019

Closed jakobnissen closed 2 months ago

jakobnissen commented 3 months ago

This code:

parse(Float32, "2e300")

Throws an error on Linux, but returns Inf32 on Windows. This reproduces all the way back to Julia 1.0.5. Ideally, parsing should behave identically on the two platforms.

vtjnash commented 3 months ago

We have had some discussion of switching to llvm's float parser in the past, since we already include it, and it is known to handle cases like this correctly and probably fairly fast

oscardssmith commented 3 months ago

imo the ideal case would be for us to switch to the parsers.jl implementation which JuliaSyntax uses since then it's pure Julia and can inline/const fold etc

KristofferC commented 3 months ago

switch to the parsers.jl implementation which JuliaSyntax uses

Does JuliaSyntax use it?

https://github.com/JuliaLang/JuliaSyntax.jl/blob/f425045d56f75c71493aba77e1b751f69f552e48/src/literal_parsing.jl#L134

ararslan commented 2 months ago

This is a duplicate of #46544. That issue is actually referenced in a comment in the JuliaSyntax float parsing code (which as Kristoffer noted does not use Parsers.jl, it calls Julia's C float parser).