Popełniłem następujący kod, podaje kilka fragmentów:

//Deklaracja:
private:
struct MatrixData
  {
   int Nr,Tm;
   double A[DataCount],B[DataCount],F[DataCount],R[DataCount];
  };
MatrixData Data;

//Metoda 1
void MatCalc::regresion1(fstream &fout)
  {
   fout.clear();
   fout.seekg(0,ios::beg);
   streampos pos=0;
   while(fout.read((char*)&Data,sizeof(Data)).gcount()==sizeof(Data))
     {
       // tu nieistotna obróbka Data
      fout.seekp(pos,ios::beg);
      fout.write((char*)&Data,sizeof(Data));
      pos+=sizeof(Data);
      fout.seekg(pos,ios::beg);
     }
  }

//Metoda 2
void MatCalc::regresion2(fstream &fout)
  {
   fout.clear();
   fout.seekg(0,ios::end);
   streampos pos=fout.tellg();
   pos-=sizeof(Data);
   fout.seekg(pos,ios::beg);
   while(fout.read((char*)&Data,sizeof(Data)).gcount()==sizeof(Data)) // problematyczna pętla
     {
      // tu nieistotna obróbka Data
      fout.seekp(pos,ios::beg);
      fout.write((char*)&Data,sizeof(Data));
      pos-=sizeof(Data);
      fout.seekg(pos,ios::beg);
     }
  }

//Wywołanie:
         fstream fout("out.mat",ios::in|ios::out|ios::binary|ios::trunc);
         // tu wywołanie metody wpisującej dane do pliku
         for(int i=0;i<4;++i)
            {
             regresion1(fout);
             regresion2(fout);
            }

Problem jest następujący:

  1. po skompilowaniu na jednym komputerze działa bez problemów.
  2. po skompilowaniu na innym komputerze nie działa "problematyczna pętla" - nie wykonuje ani jednego kroku, gcount() zwraca 0.

WTF?