This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

valarray and slice problem


2.95.2
Linux RH6.0 smp
No flags

Compiles but gives wrong anser.

nclude<valarray>
#include"stdio.h"

int main()
{
  const int J=7;
  const int K=5; 

  valarray<double> s(J+1), z(J+1);
  
  for(int k=0;k<3;++k)
    {
      s=1.;
      
      for(int k=0;k<=J;++k)
	fprintf(stderr,"s[%d]=%g  ",k,s[k]);
      fprintf(stderr,"\n");
      z=s[slice(0,K,1)];
      for(int k=0;k<K;++k)
	fprintf(stderr,"z[%d]=%g  ",k,z[k]);
      fprintf(stderr,"\n");
    }
  
  return 0;
  
}

g++ -E valarraybug.c is coming next...

Thanks,
--
Eric Ford                                         eford@princeton.edu
nux RH6.0 smp
http://www.princeton.edu/~eford/                  eford@mad.scientist.edu

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]