Bug 3701 – Incorrect initialisation of static arrays of floating-point values (Linux only)

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-01-13T00:35:00Z
Last change time
2015-06-09T01:27:14Z
Keywords
wrong-code
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2010-01-13T00:35:18Z
Example code: import std.stdio; void main() { float[1] a; writeln(a[0]); double[1] b; writeln(b[0]); real[1] c; writeln(c[0]); } One expects this program to print "nan" three times, instead it prints: 0 0 3.35109e-4932 It doesn't matter how long the arrays are, all the elements have the same value.
Comment #1 by clugdbug — 2010-02-15T00:45:45Z
Can someone confirm this? The code works correctly on Windows on 2.038 and every other version I've tried.
Comment #2 by bugzilla — 2010-02-15T01:28:56Z
Well, I'll be... Now I can't reproduce it either -- not even with DMD 2.039, which was the version I was using when I reported the bug. I swear, I tried this several times before I reported it, both on my regular OS, 64-bit Linux, and in two virtual machines, 32-bit Linux and Windows XP. There was no bug on Windows, which is why I marked the report as Linux-specific. If nobody else can reproduce this it should just be closed.
Comment #3 by ggcoding — 2010-02-15T12:00:44Z
--With 32-bit Linux and dmd 2.040 it prints: 0 0 1.6749e-4932 --With 32-bit Linux and dmd 2.039 it prints: nan nan nan
Comment #4 by hsteoh — 2012-02-15T12:03:57Z
This bug appears to have been fixed in dmd 2.057 and gdc 4.6.2, both running on Linux.
Comment #5 by hsteoh — 2012-02-15T12:04:55Z
P.S. Oh, and I tested this on 64-bit; don't know the status of 32-bit.
Comment #6 by clugdbug — 2012-02-16T08:20:43Z
(In reply to comment #4) > This bug appears to have been fixed in dmd 2.057 and gdc 4.6.2, both running on > Linux. That doesn't mean anything unless you can reproduce it on an earlier DMD -- it seems to be very platform-specific. If you can reproduce the bug on DMD 2.040, that would be fantastic, then we could close this annoying bug.
Comment #7 by hsteoh — 2012-02-16T09:39:15Z
Where can I get older versions of dmd?
Comment #8 by bearophile_hugs — 2012-02-16T10:00:43Z
(In reply to comment #7) > Where can I get older versions of dmd? Take a look at the changelog, the version numbers are links: http://www.dlang.org/changelog.html
Comment #9 by hsteoh — 2012-02-16T10:39:08Z
Hmph. I can't reproduce the problem on 2.039 and 2.040 either. :( Perhaps it's specific to 32-bit platforms. I don't think I'll be able to do anything about it unless I resurrect my old mobo. :)
Comment #10 by clugdbug — 2012-05-31T09:23:05Z
Nobody has been able to reproduce this in the last two years.