http://d.puremagic.com/issues/show_bug.cgi?id=3162

           Summary: can't fully use floats computed in CTFE as template
                    parameters
           Product: D
           Version: 2.028
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bary...@smp.if.uj.edu.pl


/** Computes square root at compile time */
real ctfe_sqrt(real x) {
  real root = x / 2.0;
  for (int ntries = 0; ntries < 10; ntries++) {
    if (root * root - x == 0)
      break;
    root = (root + x / root) / 2.0;
  }
  return root;
}

/** Square root of 2 */
static const double sqrt2 = ctfe_sqrt(2.0);
import std.metastrings;
pragma(msg, Format!("s=", cast(int)(1000*sqrt2))); // works


pragma(msg, Format!("s=", cast(int)(1000*sqrt2), " ", cast(int)(1000*sqrt2), "
")); // doesn't work
//pragma(msg, Format!("s=", cast(int)(1000*sqrt2))); // also doesn't work

pragma(msg, Format!("s=", cast(int)((1.0+sqrt2/2.0))); // doesn't works



Looks that only first occurence of value derived from constant derived using
ctfs can be used.

It was working in some older releases.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to