AnsweredAssumed Answered

Conditional expression compiler bug?

Question asked by Hrvoje Erjavec on Dec 12, 2016
Latest reply on Dec 20, 2016 by Hrvoje Erjavec


I am using S32 design studio for power architecture with MPC5744P and I have been using the conditional statements.

The shortened code looks like this:


// variable declaration for the sake of type insight

float dutyCycle;

vuint16_t a, b, c;

uint16_t inv = FALSE;

//assign a value to variable a

a = (pSub->VAL1.R * dutyCycle);

//assign a value to variable b
b = (-((int16_t)(pSub->VAL1.R * dutyCycle)));

//assign a value to variable c using a and b -> correct value
c = (inv) ? a : b;

//assign a value to variable c using statements used for assigning a and b

//-> incorrectly returns 0
c = (inv) ? (pSub->VAL1.R * dutyCycle) : (-((int16_t)(pSub->VAL1.R * dutyCycle)));


The c variable will be assigned correctly when using a and b variables, but will be 0 if the values are entered directly in the conditional expression.


Do you know what this could be about?