Re: Optimize causes an error.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just a shot in the dark, since I hate the preprocessor, try this:

#ifdef tinx
#error Oh fudge.
#endif
#ifdef size
#error Oh fudge.
#endif
#ifdef position
#error Oh fudge.
#endif
#ifdef getIndexOffset
#error Oh fudge.
#endif
#ifdef getIndexSize
#error Oh fudge.
#endif
#ifdef getDataLength
#error Oh fudge.
#endif
#ifdef fsize
#error Oh fudge.
#endif
#ifdef buffer
#error Oh fudge.
#endif
#ifdef int
#error Oh fudge.
#endif
#ifdef indexPTR_
#error Oh fudge.
#endif

HTH,
--Eljay



On 7/11/07 9:20 AM, "LWATCDR" <lwatcdr@xxxxxxxxx> wrote:

> Thanks I had some debugging printf in the code but I deleted them from
> my post to make it a little less messy but yours where better.
> This is kind of odd in that it looks like tinx is changing at random
> during execution.
> 
> 4 := (0 - 0) + 40 := 4 < 0
> 0 := testtran: ../PPDict1.cpp:65: virtual void PPDict1::getData(int,
> int, unsigned char*): Assertion `tinx >= 0' failed.
> 
> As you can see tinx is set to the value of four in the first statement
> then it throws and Assertion on the next statement! There is no
> assignments happening between the two statements.
> 
> On 7/11/07, John Love-Jensen <eljay@xxxxxxxxx> wrote:
>> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux