www.digitalmars.com         C & C++   DMDScript  

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


          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);

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



Dec 21 2015