www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16261] New: dmd -profile & nativeToLittleEndian() --> wrong


          Issue ID: 16261
           Summary: dmd -profile & nativeToLittleEndian() --> wrong result
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: johan556 gmail.com

When the -profile flag is given to dmd, a call to nativeToLittleEndian() gives
wrong result. The following code works without -profile:

  import std.stdio;
  import std.bitmanip;
  main(string[] argv)
      int value = 42;
      auto res = nativeToLittleEndian(value);
      writeln("nativeToLittleEndian(", value, ") = ", res);
      // expected output: nativeToLittleEndian(42) = [42, 0, 0, 0]
      return 0;

but with -profile it prints what seems to be garbage bytes, even different
values each time the program is  executed.

The version of the compiler was "DMD64 D Compiler v2.071.1", and I have also
built DMD from source today getting the same problem.

I also tried the example code in the documentation of nativeToLittleEndian() at
dlang.org. There too, when I build with -profile, the code does not work (gives
an assert).

Jul 10 2016