Re: *p++ = tolower(*p));



Dave Vandervies said:

In article <PdadnarcgZhod5HbnZ2dnUVZ8vydnZ2d@xxxxxx>,
Richard Heathfield <rjh@xxxxxxxxxxxxxxx> wrote:
Gunvant Patil said:


*p++ = tolower(*p));

is this behaviour defined in standards?

I took one look at it and immediately knew the answer. "No... er, hmm,
sequence points, so yes... er, hang on, er, what if..., hmm..." which
is always a good hint that it's better to re-write it to reflect what
you actually mean (which isn't clear from the code).

tolower is explicitly permitted to be, and typically is, implemented
as a macro that masks the function definition, isn't it?

Such considerations were certainly a factor in my "hang on, er, what
if". But if the choice is between, on the one hand, spending an hour
proving it from the Standard and, on the other, spending a few seconds
saying "don't be silly" and using the rest of the time to cut code,
then it's simply no contest.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: HeathField Strange Ideas!
    ... Richard HeathField in 2002. ... dictating nonsense about the ISO standards etc and sending out the ... If the standards in some way do restrict the C language, ...
    (comp.lang.c)
  • Re: static members
    ... > Richard Heathfield writes: ... snip ... ... should apply to any system meeting such standards. ...
    (comp.lang.c)
  • Re: Program without conditional Statements - Possible ?
    ... Richard Heathfield wrote: ... /Any/ one-line C program is wrong by the standards of c.l.c ... if it is to have a discernable side-effect. ... Best regards, Sidney ...
    (comp.lang.c)