Menu

#342 modulo arithmetic => Compiler Error?

None
open
nobody
None
1
2021-10-01
2021-10-01
Anonymous
No

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

2 Attachments

Discussion

  • Anonymous

    Anonymous - 2021-10-01
    Post awaiting moderation.
  • Anonymous

    Anonymous - 2021-10-01
    Post awaiting moderation.

Anonymous
Anonymous

Add attachments
Cancel