Hi,

Today thought lets learn D. I am writing a compiler for a language
and read D compiles very fast.
Switched my compiler from C++ to D and ran my test suite to use D.
Doing somethin wrong as creating array of objects gives me a segmentation fault

Example

import std.stdio;

class Pair {
  float x;
  float y;
  this() { x = 0; y = 0; }
}


void main() {
  Pair[] arr;

  // segmentation fault on next line
  arr = new Pair[](10);
  arr[0].x = 3;
  arr[0].y = 4;
  writef("arr[0] = (%f,%f)",arr[0].x,arr[0].y);
}

Reply via email to