Getting some errors when trying verify the code ([-Waggressive-loop-optimizations]) (only relevant channels are overridden)

  arduino, arduino-ide, arduino-nano, c++

Im trying to make Balancing Robot with this code https://github.com/mahowik/BalancingWii and i saw many tutorial video on this project and same code ,but no one get this error while verify the code in Arduino IDE so i thought the problem not in the code but in something on me.

i tried an old version of Arduino IDE (1.6.12) but it still giving same error.

    sketchRX.cpp: In function 'computeRC()':
sketchRX.cpp:435:26: warning: iteration 8 invokes undefined behavior [-Waggressive-loop-optimizations]
         if (rcSerial[chan] >900) {rcData[chan] = rcSerial[chan];} // only relevant channels are overridden
             ~~~~~~~~~~~~~^

sketchRX.cpp:412:25: note: within this loop
     for (chan = 0; chan < RC_CHANS; chan++) {
C:Program Files (x86)Arduinohardwarearduinoavrcoresarduinomain.cpp: In function 'main':
sketchRX.cpp:435:26: warning: iteration 8 invokes undefined behavior [-Waggressive-loop-optimizations]
         if (rcSerial[chan] >900) {rcData[chan] = rcSerial[chan];} // only relevant channels are overridden
                          ^

sketchRX.cpp:412:25: note: within this loop
     for (chan = 0; chan < RC_CHANS; chan++) {
                         ^

Sketch uses 14300 bytes (46%) of program storage space. Maximum is 30720 bytes.
Global variables use 1022 bytes (49%) of dynamic memory, leaving 1026 bytes for local variables. Maximum is 2048 bytes.

the code have many to files so i will past the part from the error

/**************************************************************************************/
/***************          compute and Filter the RX data           ********************/
/**************************************************************************************/
void computeRC() {
  static uint16_t rcData4Values[RC_CHANS][4], rcDataMean[RC_CHANS];
  static uint8_t rc4ValuesIndex = 0;
  uint8_t chan,a;
  #if !defined(OPENLRSv2MULTI) // dont know if this is right here
    #if defined(SBUS)
      readSBus();
    #endif
    rc4ValuesIndex++;
    if (rc4ValuesIndex == 4) rc4ValuesIndex = 0;
    for (chan = 0; chan < RC_CHANS; chan++) {
      #if defined(FAILSAFE)
        uint16_t rcval = readRawRC(chan);
        if(rcval>FAILSAFE_DETECT_TRESHOLD || chan > 3 || !f.ARMED) {        // update controls channel only if pulse is above FAILSAFE_DETECT_TRESHOLD
          rcData4Values[chan][rc4ValuesIndex] = rcval;                      // In disarmed state allow always update for easer configuration.
        }
      #else
        rcData4Values[chan][rc4ValuesIndex] = readRawRC(chan);
      #endif
      #if defined(SPEKTRUM) || defined(SBUS) // no averaging for Spektrum & SBUS signal
        rcData[chan] = rcData4Values[chan][rc4ValuesIndex];
      #else
        rcDataMean[chan] = 0;
        for (a=0;a<4;a++) rcDataMean[chan] += rcData4Values[chan][a];
        rcDataMean[chan]= (rcDataMean[chan]+2)>>2;
        if ( rcDataMean[chan] < (uint16_t)rcData[chan] -3)  rcData[chan] = rcDataMean[chan]+2;
        if ( rcDataMean[chan] > (uint16_t)rcData[chan] +3)  rcData[chan] = rcDataMean[chan]-2;
      #endif
      //if (chan<8 && rcSerialCount > 0) { // rcData comes from MSP and overrides RX Data until rcSerialCount reaches 0
        //rcSerialCount --;
        #if defined(FAILSAFE)
          failsafeCnt = 0;
        #endif
        if (rcSerial[chan] >900) {rcData[chan] = rcSerial[chan];} // only relevant channels are overridden
      //}
    }
  #endif
}

Source: Windows Questions C++

LEAVE A COMMENT