Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Index variable changing radically in Debug Version
    primarykey
    data
    text
    <p>I have found a lot of answers that have to do with release version problems but none with the exact opposite. </p> <p>I have a loop similar to the following:</p> <pre><code>while(index &lt; 7 &amp;&amp; FlagIsUp) { // process Inner Loop Inner Inner Loop Array[index] = number; ++index; } </code></pre> <p>Problem is that index changes radically from 6 (the last iteration) to 17209 for an int16_t and 1133165442 for size_t. NOTHING IN THE LOOP changes the index except the ++index. I replaced the while with a for and it still happens.</p> <p>It only happens in debug mode, in release version it does finish without issues.</p> <p>I also added volatile to the index and results were the same, it still overflowed.</p> <p>Any ideas, pointers, would be appreciated. I can't provide a working copy of the bug so any theories are welcomed, I want to exhaust my options to find the problem.</p> <p>EDIT: Yes I'm sorry. I gave to little information. First off I'm working with QNX Momentics Version: 4.6.0 and my debugger is part of the GNU Compiler Collection 4.3.3.</p> <p>Now the inner loop is this:</p> <pre><code>cSignalNoIndex = 0; while ((cSignalNoIndex &lt; (2 * NO_PHASES + 1)) &amp;&amp; !ShutDownFlag) { wSF0 = 0; wExtSF = 0; dwSFAcc = 0; dwExtSFAcc = 0; std::string SignalNo= " Waveform number " + Tool::toString(cSignalNoIndex); Results[cSignalNoIndex].printWaveForm(SignalNo); // Prepare Input vectors for FFT compute cComponent = 0; while (cComponent &lt; (HCYCLE_SAMPLES &lt;&lt; 1)) { awReal[cComponent] = static_cast&lt;int&gt;(Results[cSignalNoIndex].WaveForm[cComponent/64][cComponent % 64]); awImg[cComponent] = 0; pwSource++; cComponent++; } Results[cSignalNoIndex].printWaveForm(SignalNo); // Get FFT (forward) // Changed the wPwr from 7 to something else iFft(&amp;awReal[0], &amp;awImg[0], wPwr, 1); Results[cSignalNoIndex].printWaveForm(SignalNo); // Compute magnitudes //fMult = pInBlock3-&gt;fMult[cSignalNoIndex]; // Get Multiplier fMult = 1; for (cComponent = 0; cComponent &lt; HCYCLE_SAMPLES &amp;&amp; !ShutDownFlag; cComponent++) { int64_t dlOp = static_cast&lt;int64_t&gt;(awReal[cComponent]) * awReal[cComponent] + static_cast&lt;int64_t&gt;(awImg[cComponent]) * awImg[cComponent]; dlOp &lt;&lt;= 1; // Apply sqrt(2) term to result dlOp = static_cast&lt;int&gt;(fMult * isqrt64(dlOp)); // Store into FFT object oFFTMag3.wFFT[cSignalNoIndex][cComponent] = static_cast&lt;int16_t&gt;( dlOp ); // Set Base frequency magnitude and accumulate harmonics if (cComponent == 1) // Base { wSF0 = dlOp; if(cSignalNoIndex == 6) { wRefMagnitude = static_cast&lt;int16_t&gt; ( 0.4 * wSF0 ); } if(awReal[1] != 0) // Also get phase for Base { dfPhase = std::atan((double)((float)awImg[1]/awReal[1])) * 180.0 / PI; } else { if(awImg[1] &gt;= 0) { dfPhase = 90.0; } else { dfPhase = -90.0; } } if(awReal[1] &lt; 0) // convert to 2*PI range { dfPhase += 180.0; } else if(awImg[1] &lt; 0) { dfPhase += 360.0; } //// THIS IS THE LINE fPhase[cSignalNoIndex] = dfPhase; ////////// WTF! cSignalNoIndex = 6 - cComponent = 2 /// HERE cSignalNoIndex is overflown } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload