While developing with D (DMD64 D Compiler v2.067.0 on MacOS 10.10.3) I had a program with an unexpected behaviour and I reduced it to the minimal form below. The error as indicated in the comment is that the function call pvi_calc changes int_1 when I think it should not. The result copied below.

I hope this helps. Kind regards
John Nixon


import std.stdio;
int n,cp;
double[] pvi,int_1,int_2;

void pvi_centre(const int centre){
  int_1=pvi_calc(centre);
  writeln("int_1 = ",int_1);
  int_2=pvi_calc(n-1-centre);//pvi_calc is changing int_1!
  writeln("int_1 = ",int_1);
  return;}

double[] pvi_calc(const int n1){
  for(int i=0;i<=n1;++i)pvi[i]= 1;
  return pvi;}

int main(){
  n=10;
  pvi.length=n;
  int_1.length=int_2.length=n;
  pvi_centre(cp);
  return 0;}
~

int_1 = [1, nan, nan, nan, nan, nan, nan, nan, nan, nan]
int_1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

Reply via email to