Richard F wrote:
[in] rtc.time_element.tm_wday = (rtc.time_element.tm_wday < 6) ?
rtc.time_element.tm_wday++ : 0;
... the expression rtc.tm_wday++ doesn't appear to be evaluated.
If the conditional expression evaluates TRUE, the statement reduces to this:
rtc.time_element.tm_wday = rtc.time_element.tm_wday++;
The C language is defined such that the RHS will be evaluated completely
before assignment to the variable on the left. So what happens is that the
value of rtc.time_element.tm_wday is retrieved and stored,
rtc.time_element.tm_wday is then incremented and, finally, the stored value
(the original value of rtc.time_element.tm_wday) is assigned to
rtc.time_element.tm_wday (wiping out the increment). The compiler is at
liberty to optimize away the redundant increment (unless
rtc.time_element.tm_wday is declared volatile, in which case it would be
incremented and then put back where it was).
Graham.
_______________________________________________
AVR-GCC-list mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list