Re: A note on personal corruption as a result of using C



In article <a300aa54-a28b-4828-9290-21e98a8b4c9c@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, spinoza1111 <spinoza1111@xxxxxxxxx> writes
(Sigh). The PROBLEM was that you used an invariant and you counted on
the compiler to optimize.

Why is that a problem? That is precisely what compilers are supposed to do.

It has been the practice in the past to
assault posters for this practice here

I see no evidence of this whatsoever. Please post a pointer to an article where somebody was "assaulted" for using an optimisable invariant in a for loop. Note that strlen() is not an optimisable invariant.

Incidentally, all I've seen in your case is Richard pointing out that it would be more efficient to store the length in a variable. Not just because of the loop, but for a couple of other uses of it in the same function. Hardly "assault". Certainly not comparable with your ranting because I pointed out a minor bug in your stack machine code.

but you were not assaulted
because you're a one of the thugs. You want a free pass

Usual Nilges rant.

for plus one
which is in some situations optimized by the compiler and in other
situations not:

I would expect it to be optimised any time I select optimisation by the compiler and it's optimisable.

but strlen can also be a constant expression

[Nitpick: "constant expression" is a technical term which this isn't an instance of. But ignoring that ...]

Yes, it can. However, the compiler can not - absent unusual circumstances which I don't think applied to your code - it can't be detected as such by the compiler. Therefore it would be unusual for it to even attempt to do so.

whereas
in OTHER situations plus one may not be.

Example? Where the loop condition is an invariant, I mean. Obviously if it's altered within the loop, the plus one probably can't be optimised away.

You combine only a superficial, nonpractitioner's knowledge with the
willingness to create confusion because (as we know) you're a
politician who has long replaced competence with the willingness to
transform technical issues to personal vendettas.

"We" don't know anything of the sort. And this isn't a "vendetta" - stop posting lies and libel about me, and I'll stop pointing out to the world where you're doing so.

--
Clive D.W. Feather | Home: <clive@xxxxxxxxxx>
Tel: +44 20 8495 6138 (work) | Web: <http://www.davros.org>
Fax: +44 870 051 9937 | Work: <clive@xxxxxxxxx>
Please reply to the Reply-To address, which is: <clive@xxxxxxxxxx>
.



Relevant Pages

  • Re: Larkin, Power BASIC cannot be THAT good:
    ... Using DDR2 ram execution is roughly 2s and older DDR ram is about 3s in execution. ... A cache aware version of this vector add and accumulate is about 15% faster than the simple loop on a good optimising compiler (actually that is measured on MSC I haven't checked its code generation for optimisation - too tedious). ...
    (sci.electronics.design)
  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... it's a for loop in the C sense. ... > sloppy thinking that results from confusing a programming language ... >> I do not believe that you are capable of writing a conforming C compiler. ... Does Microsoft's C compiler perform this optimisation? ...
    (comp.programming)
  • Re: RAD vs. performance
    ... abstractions that will be there, whereas my compiler can optimize them ... Usually this doesn't matter, though. ... I'd say the same thing about your premature optimisation ...
    (comp.lang.misc)
  • Re: simple increment operator question.
    ... The Real OS/2 Guy wrote: ... > compiler to make optimasions right. ... > optimisation ability will produce better code for ... If find it sadly ironic that someone so concerned with the readability ...
    (alt.comp.lang.learn.c-cpp)
  • Re: GNUH8 mixed C and assembly
    ... Using a volatile variable forces the compiler to include the loop and seems also to make the loop timing invariant with optimisation level. ...
    (comp.arch.embedded)