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

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

Re: [avr-gcc-list] Feature request - compiler warning for "if" stmtsthat


From: Douglas Dotson
Subject: Re: [avr-gcc-list] Feature request - compiler warning for "if" stmtsthat do nothing
Date: Tue, 14 Dec 2004 06:18:19 -0800 (PST)

--- Dave Hansen <address@hidden> wrote:

> From: address@hidden
> [...]
> >And also good style; I hate it when I see an empty
> loop done as
> >
> >     while (*a++ = *b++);
> >
> >It makes it so much more obvious you meant it to be
> empty when you
> >instead do
> >
> >     while (*a++ = *b++)
> >             ;
> >
> >Or even better
> >
> >     while (*a++ = *b++)
> >             ; /* empty */
> >
> 
> My preference is something like
> 
>    while (*dst++ = *src++)
>       continue;

Won't this generate extra code (an extra jump)? Or
does the optimizer take it out? My concern is that
using the "continue" kind of obscures the meaning
of the code. One has to think about the intent rather
than the ; which is immedeately obvious.

> Regards,
>    -=Dave
> 
> 
> 



reply via email to

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