-
Notifications
You must be signed in to change notification settings - Fork 527
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
[Win32] Inclusion of '-std=c99' flag in 32-bit builds of perl leads to anomalies in XS arithmetic. #22199
Comments
Although adding |
After looking over this... First, I think your example is non-portable, the decimal value isn't precisely equal to the hex version, and the standard allows the compiler to take advantage of any extra precision it has access to, from c99 6.3.8.1 paragraph 2:
I suspect this is why the compiler treats the comparison as false under Note in both cases, with or without We could remove the Adding |
I sense that we might be able to classify the problematic C code as badly written code - or, perhaps we could argue that the assumption that the equivalence will be true is without basis. That would mean that we can just close this Issue and do nothing else (because there really is nothing else to do). As you point out, it's not hard to alter the code so that it DWIMs. |
I think it's reasonable to close it. |
4 things to note:
-std=c99
flag to $Config{ccflags};My suggested fix is to have win32/GNUmakefile add the
-ffast-math
flag to perl's$Config{ccflags}
.See information provide by Liu Hao at:
https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/CADZSBj04E%2BYaCYDiKRSX6gqNEqLW9u99T2zCFszPeLZbhDjCCw%40mail.gmail.com/#msg58769159
Does that suggested fix seem reasonable ?
I envisage that the addition of the
-ffast-math
flag can be made to both 64-bit and 32-bit builds ..... or would we want to limit it to the 32-bit build only ?Description
Inside XS code, a decimal literal floating point value will (for many values) be considered unequal to the same value expressed as a hex string literal.
Steps to Reproduce
A simple C demo program to build (with/without
-std=c99
/-ffast-math
):An Inline::C script:
Expected behavior
Expected output of the Inline::C script:
Actual output of the Inline::C script:
(Uncomment the "CCFLAGSEX..." line in the Inline::C script to obtain expected output.)
Perl configuration
The text was updated successfully, but these errors were encountered: