2009/2/10 Oleksandr Redchuk <[email protected]>: > Use pre-increment. > > rtc.time_element.tm_wday = (rtc.time_element.tm_wday < 6) ? > ++rtc.time_element.tm_wday : 0;
Sorry, pre-increment also is "UB" because of undefined order of store-back operation for pre-increment and assignment. The only correct version rtc.time_element.tm_wday = (rtc.time_element.tm_wday < 6) ? rtc.time_element.tm_wday+1 : 0; Again: > But on my taste > > if( ++rtc.time_element.tm_wday >= 6 ) rtc.time_element.tm_wday = 0; > > is better solution (generates smaller code) -- wbr, ReAl _______________________________________________ AVR-GCC-list mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
