www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15466] New: Incorrect result for 'real'

https://issues.dlang.org/show_bug.cgi?id=15466

          Issue ID: 15466
           Summary: Incorrect result for 'real'
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: acehreli yahoo.com

I was able to reduce the code to the following, which involves
std.datetime.benchmark. However, I have not investigated whether this is a
compiler or Phobos bug. Hence the vague subject. :(

The bug manifests itself only if the four conditions are satisfied in the
reduced code (-O, -inline, etc. do not make any difference):

import std.stdio;
import std.datetime;

alias T = real;     // Must be 'real'
enum testCount = 7; // Must be > 6

T foo() {           // Must return a value
    return 42;
}

void main() {
                    // Must cast to void
    const m = benchmark!(() => cast(void)foo)(testCount);
    writeln(m[0].msecs);
}

The output of the program (test measurement) is not 0 (or a very small number
of milliseconds) as one would expect:

-9223372036854775808

Ali

--
Dec 21 2015