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 d


From: Douglas Dotson
Subject: Re: [avr-gcc-list] Feature request - compiler warning for"if"stmtsthat do nothing
Date: Fri, 17 Dec 2004 07:16:56 -0800 (PST)

When C started to become really popular, Structured
Programming was in it's heyday and GOTO-less 
programming was the mantra. The "break" and
"continue" statements are just forms of a GOTO,
although more controlled. There were alot of
programming "rules" that prohibited the use use GOTO.
One company I know of even went so far as to terminate
programmers that dared to use one. These days
we tend to be more enlightened and understand that
all these constructs can have their uses if used
wisely. These MISRA guidelines seem to me to be just
another in a very long line of attempts to make
programs better by enforcing rules. My experience
is that success using this approach is questionable
at best.

Doug

--- Anton Erasmus <address@hidden> wrote:

> On 14 Dec 2004 at 9:26, E. Weddington wrote:
> 
> > David Breeze wrote:
> > 
> > >
> > >>I can't resist any longer.  I always do this:
> > >>    
> > >>
> > >
> > >  
> > >
> > >>while ( *a++ = *b++ ) { }
> > >>    
> > >>
> > >
> > >  
> > >
> > >>This seems to me to state clearly that I haven't
> forgotten the body
> > >>and that I intend it to be empty.
> > >>    
> > >>
> > >
> > >  
> > >
> > >  
> > >
> > 
> > Oh, all right, I'll chime in too.
> > 
> > I also do the above for the same reason. If
> someone *really* wanted to
> > be pedantic, they could put in a comment:
> > 
> > while(*a++ = *b++)
> > {
> >     // Intentionally empty.
> > }
> > 
> > 
> > >Better!  Also for those of us where safety is an
> issue "continue" and
> > >"break" statements from while or for loops are to
> say the least
> > >frowned upon/banned.  See MISRA guidelines.
> 
> The latest misra guidelines has the following to
> say:
> 
> Rule 14.5 (required): The continue statement shall
> not be used.
> 
> > >
> > 
> > Do you have link to a free copy of the MISRA
> guidelines?
> > 
> A downloadable pdf version from MISRA itself is
> quite reasonably priced. Definately a 
> worthwhile document to have even if one do not code
> according to their guidelines. 
> 
> Regards
>   Anton Erasmus-- 
> A J Erasmus
> 
> 
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
> 



reply via email to

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