MinGW and MSVCRT Conflict Causes Floating-Point Value Corruption
jones_supa writes: If you are working on a C++ program where you need very accurate floating point numbers, you might have decided to use long double data type for the extra precision. After a few calculations, you happen to print your number. To your shock, instead of the number being 123.456789, it is printed out as -6.518427 × 10^264 (or 2.745563 depending on your computer). This is actually a bug in some versions of MinGW g++ 4.8.1 (MinGW is a port of GNU programming tools for Windows). Microsoft's C++ runtime library reserves 80 bits for double and long double. When MinGW uses the Microsoft DLL to print out the value, the number is interpreted as using only 64 bits. This discrepancy causes garbage results to be output.
Compiler bugs are news ?
You used Windows for floating point maths and got the wrong answer? Surely not!
Sent from my ASR33 using ASCII
Let me guess, you are running this in boot camp on an intel bad d apple.
The title implies that the floating point value becomes corrupt. Without looking into it, it sounds like the value does not become corrupt but rather is just not output correctly. The underlying value is still intact.
ok?
Try doing the same thing on an original Pentium.
Get free satoshi (Bitcoin) and Dogecoins
This is well known. I had a bug in a tree class due to this. The key stored in the instance was 64 bit, but the compare class evaluated and compared it in 80 bits. One of the most difficult bugs I ever encountered. Highly recursive calls to the compare function failing once in about a billion calls... But that was almost 10 or 12 years ago.
But one thing. GCC handled the truncations correctly. It allows the 80 bit evaluations turned off by compiler options. I don't mix GCC with msvcrt so I am not sure how old / new this is. My 80 bit adventure was in Linux on Intel chips.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
... this is better than posting stories about SourceForge getting caught highjacking the dev accounts of major OSS projects I guess.
So, it's basically JAVA Compatible, ignoring the IEEE-754 specification.
64 bits should be enough for anybody
It's nice to know that one can rely on Microsoft to do the stupid thing.
But once I've debugged my software and uploaded it to SourceForge can I be sure it won't have an advertising spyware package added to the installer by DICE?
For 64-bit apps, Microsoft defaults to full precision (80-bit long doubles, that is, 64-bit mantissa).
Check it in float.h (the _PC_53 part, as in Precision Control):
#if defined (_M_IX86)
#define _CW_DEFAULT ( _RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
#elif defined (_M_X64) || defined (_M_ARM)
#define _CW_DEFAULT ( _RC_NEAR + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
#endif
I don't see what makes it worth a Slashdot posting reading the blog post, it's actually 1. specific to an old g++ version (4.8), and does not occur in the two more recent versions (4.9 and 5.1); 2. specific to a certain build of g++ on mingw; others are not impacted.
In short: much ado about very little.
Gnu C "long double" is 16 bytes long and most decidedly does not fit into 80 bytes.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
That should be "80 bits"...
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
We are on 4.9.2 even on windoze... just sayin... old news is old news...
It's the other way around. long double is 80 bits long and most decidedly does fit into 16 bytes, which is does so presumably for alignment purposes.
systemd is Roko's Basilisk.
SourceForge, the code repository site owned by Slashdot Media, has apparently seized control of the account hosting GIMP for Windows on the service, according to e-mails and discussions amongst members of the GIMP community—locking out GIMP's lead Windows developer. And now anyone downloading the Windows version of the open source image editing tool from SourceForge gets the software wrapped in an installer replete with advertisements.
http://arstechnica.com/informa...
The GIMP developers aren't happy at all about this. They say that Sourceforge impersonated the GIMP developers, and abused the trademarks owned by the GNOME foundation.
https://mail.gnome.org/archive...
and this post will not change my mind. Even if I had to use a proprietary but otherwise free compiler on windows, I would definitely go with pellesc and not msvc.
As far as c++ is concerned, I am idiot and cannot understand it. So I avoid it.
the question is whether this bug affects dmd or pocc.
a datatype of "long double" is truly irrelevant, and an utter representation of stupidity.
WTF is a "short double"?
The true problem is a mhoronic presumtion that MSVC is relevant. FALSE.
A double is 64-bits. A float is is 32-bits. A half-float is 16 bits (only pertinent to ship-dits that believe that 80 bit 'floats' are useful.)
See subject: From http://slashdot.org/comments.p... ?
Your "DNS lookup" b.s.?
1st: Hosts exceed SLOWER remote DNS lookup (Exploit ridden by Kaminsky redirect flaw & 99.999% of ISP DNS != patched vs. it!) - how?
I avoid DNS putting WHERE I SPEND 95%++ ONLINE TIME @ TOP OF HOSTS via 30 favs!
2nd: AdBlocking gains speed!
BOTH exceed remote DNS lag indexed lookup post query/turnaround on resolution (do the math binary search) over 3++ million records w/ a most efficient blocking format = better load + internal parse & no bloat in hosts cached in LOCAL RAM via 2 kernelmode subsystems (diskcache & ip stack = no usermode context switch overhead like Windows' faulty w/ large hosts files usermode dns cache service) vs. remote DNS for utmost in speed, efficiency + reliability (my program keeps hardcodes current) vs. downed DNS too.
* Hosts = MORE SPEED + EFFICIENCY & ease of maintenance (via http://start64.com/index.php?o...) versus.:
1.) Remote DNS & hosts do so w/ less resource use + added on app complexity/room for breakdown & exploit w/ added CPU & power use w/ a local setup DNS (worse if separate system) + complexity of deny rules vs. hosts simple entries
+ vs.
2.) "Almost ALL Ads Blocked": Hosts are far more efficient doing more w/ less vs. AdBlock's BLOAT & regex complexity vs. hosts simple entries. Addons add overheads layered over slower browsers in usermode increasing messagepassing overheads vs. hosts in kernelmode (run some addons concurrently see what I mean). Addons do more added I/O operations + consume more memory & create CPU overuse + complexity (regex vs. hosts entries) bolted-on in SLOW usemode vs. hosts in PURE kernelmode via a high cpu serviced layer of ops by IP stack. Addons = easily detected by native browser methods + clarityray shuts 'em down (hosts aren't).
APK
P.S.=> + Hosts != bribed (like AdBlock/ABP NOT DOING THE 1 JOB IT HAD by default)... apk
It has to do that because arrays of types are required to not have gaps between elements (so that address arithmetic works), and on the other hand they all have to be properly aligned. For modern Intel CPUs, the proper alignment for an 80-bit float is 8 bytes. Hence the smallest value that is equal to or greater than 10 bytes (80 bits) that is divisible by 8 - 16 bytes.
See subject: From http://slashdot.org/comments.p... ?
Your "DNS lookup" b.s.?
1st: Hosts exceed SLOWER remote DNS lookup (Exploit ridden by Kaminsky redirect flaw & 99.999% of ISP DNS != patched vs. it!) - how?
I avoid DNS putting WHERE I SPEND 95%++ ONLINE TIME @ TOP OF HOSTS via 30 favs!
2nd: AdBlocking gains speed!
BOTH exceed remote DNS lag indexed lookup post query/turnaround on resolution (do the math binary search) over 3++ million records w/ a most efficient blocking format = better load + internal parse & no bloat in hosts cached in LOCAL RAM via 2 kernelmode subsystems (diskcache & ip stack = no usermode context switch overhead like Windows' faulty w/ large hosts files usermode dns cache service) vs. remote DNS for utmost in speed, efficiency + reliability (my program keeps hardcodes current) vs. downed DNS too.
* Hosts = MORE SPEED + EFFICIENCY & ease of maintenance (via http://start64.com/index.php?o...) versus.:
1.) Remote DNS & hosts do so w/ less resource use + added on app complexity/room for breakdown & exploit w/ added CPU & power use w/ a local setup DNS (worse if separate system) + complexity of deny rules vs. hosts simple entries
+ vs.
2.) "Almost ALL Ads Blocked": Hosts are far more efficient doing more w/ less vs. AdBlock's BLOAT & regex complexity vs. hosts simple entries. Addons add overheads layered over slower browsers in usermode increasing messagepassing overheads vs. hosts in kernelmode (run some addons concurrently see what I mean). Addons do more added I/O operations + consume more memory & create CPU overuse + complexity (regex vs. hosts entries) bolted-on in SLOW usemode vs. hosts in PURE kernelmode via a high cpu serviced layer of ops by IP stack. Addons = easily detected by native browser methods + clarityray shuts 'em down (hosts aren't).
APK
P.S.=> + Hosts != bribed (like AdBlock/ABP NOT DOING THE 1 JOB IT HAD by default)... apk