emontx3 icon indicating copy to clipboard operation
emontx3 copied to clipboard

emonTx34_CM - for loop out of bounds

Open stuartpittaway opened this issue 2 years ago • 0 comments

Receiving a compile warning in emonTx34_CM and emonLibCM.

The for loop is defined for 6 iterations, but the wh_CT[] array is only sized to 5 items.

Linking .pio\build\default\firmware.elf
C:\Users\stuar\.platformio\packages\framework-arduino-avr\cores\arduino\main.cpp: In function 'main':
.pio\libdeps\default\EmonLibCM\emonLibCM.cpp:415:20: warning: iteration 5 invokes undefined behavior [-Waggressive-loop-optimizations]
     wh_CT[channel] = _wh;
                    ^
E:/source/emontx3/firmware/emonTx34/emonTx34_CM/emonTx34_CM_config.ino:417:25: note: within this loop
         for (byte n=0; n<6; n++)
                         ^
Checking size .pio\build\default\firmware.elf

stuartpittaway avatar Sep 10 '23 13:09 stuartpittaway