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: Anton Erasmus
Subject: Re: [avr-gcc-list] Feature request - compiler warning for"if"stmtsthat do nothing
Date: Fri, 17 Dec 2004 22:02:17 +0200

On 17 Dec 2004 at 7:16, Douglas Dotson wrote:

> 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.


I agree with you. The new MISRA 2 have much more content regarding
why they made a specific rule. This information is the useful information in
the MISRA guides. It is then much easier to justify (on technical merit) the
 breaking of a rule or guide-line. The MISRA standard allows the breaking of
any of the rules - it just needs to be justified on technical merit.
Slavishly following any rule - without understanding the reasoning behind the 
rule
is a recipe for disaster.

Regards
   Anton Erasmus


> --- 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
> > 
> 

-- 
A J Erasmus



reply via email to

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