www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Bug 115] New: Union literals as rvalues yields different values

Date: Sat, 5 Apr 2014 22:32:44 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"

http://bugzilla.gdcproject.org/show_bug.cgi?id=115

            Bug ID: 115
           Summary: Union literals as rvalues yields different values
                    every run
    Classification: Unclassified
           Product: GDC
           Version: 4.8.x
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gdc
          Assignee: ibuclaw gdcproject.org
          Reporter: klas.bjorkqvist gmail.com

When running the following program:

a.d
------
import std.stdio;

union _f {
  float f;
  uint i;
}

void func(const uint x) {
  writeln(x);
}

void main() {
  float a = 123.0;
  const l = _f(a);
  func(l.i);
  func(_f(a).i);
}
----

multiple times, the value printed for "_f(a).i" is different each time, and
appears mostly random when compared to the value of "l.i". 

 gdc a.d && ./a.out
1123418112 430703264
 ./a.out           
1123418112 3680514720
 ./a.out
1123418112 2543067808 -- You are receiving this mail because: You are watching all bug changes.
Apr 05 2014