On Sep 22, 2004, at 4:24 PM, James Giles wrote:
> Richard E Maine wrote:
>> Ouch. I wouldn't trust it. According to me it is invalid. And I'd bet
>> that someday you'll run into a compiler that figures it would be a
>> good idea to optimize the 4 add1 calls by doing it just once.
> Unless ADD1 is declared PURE, that "optimization" would be a violation
> of the standard...
As usual (meaning at least the last dozen or to times that it has come
up), Giles and I disagree on this subject. I'll not try to argue it
again. The only reason I posted is because I thought that some of the
elided wording could be read to imply that even those of us who dispute
his interpretation would agree with that. No, I don't care either to
dispute exactly what was or wasn't said - just to point out that,
regardless of anything that might have been said, implied, or just
misread by me, I do disagree.
One note that I don't think I mentioned before in this thread. If you
take my advice in avoiding the practice of depending on function side
effects, then you are completely 100% safe in this regard, no matter
who is correct about any related point. Even if I am conclusively
determined to be wrong about everything else on this subject, even if
compilers screw it up, following my advice on it is still safe.
If you depend on side effects, well maybe you are still safe. Maybe
Giles is right. Maybe all the compilers you use will agree. Maybe your
particular code won't stray into areas that have any problems on any of
the compilers. Maybe the odds of this all are even good.
I call attention to the "maybe"s in the above para.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|