This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc volatile behaviour


"Robert J. Brown" <rj@eli.elilabs.com> wrote:

 > [ ... ]

I've contaced the C standard committee and they told me that this is
untrue that the standard says that the LHS of an assignment has to be
re-eftched. Please see my other post to the list.

 > IMO since the man page defines the terminator wrt the source string,
 > then the above implementation of strcpy is flawed!  Volatile should
 > have nothing to do with it this time.

Well, if this strcpy is flawed, then Dennis Ritchie should be dragged
to the stake because he implemented strcpy() this way ...
If you have Kernighan - Ritchie: The C Programming Language, Second
Edition (ANSI C), take a look at page 105, which says:

 " ... In practice strcpy would not be written as we showed it
  above. [Note that *all* of their previous versions rely on the 
  value of an assignment being that of the RHS. - Zoltan] 
  Experienced C programmers would prefer

       /* strcpy: copy t to s; poijnter version 2 */
       void strcpy(char *s, char *t)
       {	   
            while ((*s++ = *t++) != '\0')
               ;
       }
  ... "


Apart from it being obvious from all of the strcpy versions, the
following excerpt (also on page 105) indicates too that K&R believe 
that the value of the assignment is the the value *written* to the 
LHS and not what is read back:

  "... the postfix ++ doesn't change t until this character has been 
   fetched. In the same way, the character is stored into the old s
   position before s is incremented. This character is also the value
   that is compared against '\0' to control the loop. ..."
   
Since Dennis Ritchie IMHO is reasonably authentic in the intended
semantics of the various constructs in the C language, I'd say that 
if his own description of his own language is flawed in the light of 
the standard, then there's something wrong with the standard.
Not to mention that the generation of C programmers who grew up on the
above mentioned book (and its predecessors - the *only* C books at the 
time) will also all be rather confused.

I've contated Dennis Ritchie, and he wrote me that in his oppinion the 
wording of the standard (WRT assignment operators) is ambiguous. 
According to the standard committee this ambiguity is deliberate and 
is not ambiguity but freedom. 
I'm asking for the excercising of this freedom in gcc the other way :-)

Best Regards,

Zoltan

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]