Message: 8 Date: Tue, 10 Feb 2009 14:15:27 +0200 From: Oleksandr
Redchuk <r...@real.kiev.ua> Subject: Re: [avr-gcc-list] compiler bug?
To: avr-gcc-list@nongnu.org Message-ID:
<f269dc9a0902100415y68e6887bwe163f3e6e4d05...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1 2009/2/10 Oleksandr
Redchuk <r...@real.kiev.ua>:
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)
Thanks Oleksandr
I reverted to the 3 line full version, all explicit statements to avoid
confusion.
FYI The compiler does not produce any warning with -Wall (my default config)
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list