Skip to content
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

[Win64] real constants parsed as 0 #761

Closed
Trass3r opened this issue Oct 24, 2014 · 10 comments
Closed

[Win64] real constants parsed as 0 #761

Trass3r opened this issue Oct 24, 2014 · 10 comments
Labels

Comments

@Trass3r
Copy link
Contributor

Trass3r commented Oct 24, 2014

Lexer::inreal calls Port::strtold to parse the real constants in std.math.

enum real PI =         0x1.921fb54442d18469898cc51701b84p+1L;

This maps to the msvc strtold and just returns 0, also see #747.

@Trass3r
Copy link
Contributor Author

Trass3r commented Oct 24, 2014

@dnadlinger
Copy link
Member

Didn't somebody pull the related code out of the MinGW CRT so we could use it? (@kinke maybe?)

@kinke
Copy link
Member

kinke commented Oct 25, 2014

I didn't. We've previously used DMD/DMC's strtold() implementation back when real was 80 bits; we'd now actually need a C99-compliant strtod() for real == double. Imho, the best course of action is to continue using MSVC's strtold() but to require MSVC 2014+ as soon as it's released. It simply represents a big leap in terms of portability with its C99 conformance, as the linked MSDN blog shows.
In this case, MS also increased the accuracy when parsing floating points: The old parsing algorithms would consider only up to 17 significant digits from the input string and would discard the rest of the digits. [...] The new implementation considers all present digits and produces the correctly rounded result for all inputs (up to 768 digits in length).

@Trass3r
Copy link
Contributor Author

Trass3r commented Oct 25, 2014

Even then we need to add a warning at least. It can't just silently use 0.0
How does dmd deal with invalid float literals?

@dnadlinger
Copy link
Member

How would invalid float literals be relevant here?

@Trass3r
Copy link
Contributor Author

Trass3r commented Oct 25, 2014

Just wondering if they do error checking on the strtold call or inside.

@dnadlinger
Copy link
Member

Invalid literals shouldn't even make it to the strtold call in the lexer.

@Trass3r
Copy link
Contributor Author

Trass3r commented Oct 25, 2014

Makes sense.

@redstar
Copy link
Member

redstar commented Mar 6, 2015

The compiler part is hopefully fixed with commit 2fdd4fe.

@kinke
Copy link
Member

kinke commented Mar 29, 2017

FWIW, although we only support VS 2015+ anymore, this is fixed by #2054.

@kinke kinke closed this as completed Mar 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants