This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Optimize causes an error.
- From: John Love-Jensen <eljay at adobe dot com>
- To: LWATCDR <lwatcdr at gmail dot com>, MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Wed, 11 Jul 2007 06:47:45 -0500
- Subject: 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