avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] compiler bug?


From: Oleksandr Redchuk
Subject: Re: [avr-gcc-list] compiler bug?
Date: Tue, 10 Feb 2009 14:15:27 +0200

2009/2/10 Oleksandr Redchuk <address@hidden>:

> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]