This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Optimize causes an error.


Here's what I'd do... first grade debugging.  Add in these diagnostic lines:

void PPDict1::getData(int position, int size, unsigned char *buffer) {
  int fsize = getDataLength();
  if ((position + size) > fsize) {
    memset(buffer, 0, size);
    return;
  }
  int tinx=(position-getIndexOffset())+size;

// Which of these things has the unexpected value?
  assert(tinx >= 0);
  assert(getIndexSize() >= 0);
  assert(getIndexOffset() >= 0);
  bool const haveMoreTinx = tinx < getIndexSize();
  bool const isPtrNonZero = indexPTR_ != 0;
  std::cerr << tinx << " := (" << position << " - "
    << getIndexOffset() << ") + " << size;
  std::cerr << haveMoreTinx << " := " << tinx << " < " << getIndexSize()
    << '\n';
  std::cerr << isPtrNonZero << " := " << indexPtr_ << " != 0\n";
  std::cerr << haveMoreTinx << " && " << isPtrNonZero << '\n';

  if((tinx<getIndexSize())&&(indexPTR_!=0)){
    inxcount_++;
    void * tPtr=indexPTR_+position-getIndexOffset();
    memcpy(buffer, tPtr, size);
  }else{
    dictStream_.seekg(position);
    dictStream_.read((char *)buffer, size);
    profcount_++;
  }
}

HTH,
--Eljay


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