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

           Summary: CTFE breaks
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: iteronve...@gmail.com


--- Comment #0 from iteronve...@gmail.com 2012-04-18 21:12:05 PDT ---
DMD 2.059 64-bit Gnu/Linux

----------------8<----------------8<----------------
import std.typecons  : Tuple;
import std.array     : appender;
import std.algorithm : sort;
import std.stdio     : writeln;

alias double Real;

struct S {

  Tuple!(uint, Real)[] _data;
  alias _data this;
}

private auto gen(K, V)(V[K] data) {
  alias Tuple!(K, V) T;
  auto app = appender!(T[]);
  foreach(k, v; data)
    app.put(T(k, v));
  sort(app.data);
  return app.data;
}

auto s(Real[uint] data) {
  return S(gen!(uint, Real)(data));
}

static S s1 = s([1: 12.0, 5: 4.6, 3: 9.99]);

void main() {

  S s2 = s([1: 12.0, 5: 4.6, 3: 9.99]);

  // prints [Tuple!(uint,double)(0, nan), Tuple!(uint,double)(0, nan),
Tuple!(uint,double)(0, nan)]
  writeln(s1);

  // prints [Tuple!(uint,double)(1, 12), Tuple!(uint,double)(3, 9.99),
Tuple!(uint,double)(5, 4.6)]
  writeln(s2);
}
---------------->8---------------->8----------------

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

Reply via email to