I've simulated the behaviour of the STM32-Compiler also with TDM-GCC (5.1.0 & 10.3.0) with the same result - for values like cnt24b == -32703 and tp == 32735 the compare in the following lines will produce differnt results depending on weather the difference of the left side of compare will be assinged to a temporary variable or not!
if ( ((( (int16_t) nextTp - ((int16_t) (cnt24b))) > (int16_t) 0)) ) { if ( (((tmp = (int16_t) nextTp - ((int16_t) (cnt24b))) > (int16_t) 0)) ) {
I think, in both cases the result of the second one should be produced.
Using Microsoft Visual Studio will produce in both cases (with and without asigning the difference to a temporary variable) the behaviour I know from all 16bit MCUs and their compilers.
My case on ST web side:
https://community.st.com/s/question/0D53W000016nKEYSA2/stm32cubeide-v170-modulo-arithmetic-compiler-error
Anonymous