J
JohnF
A while back (in a thread I'm no longer seeing on my newsreader)
you all convinced me strcpy(s,s+n) is a really bad idea, and
I indeed changed code accordingly. Of course, I was always aware
it's formally wrong, but also aware it usually works just fine.
Unfortunately, some unchanged code (I couldn't go back and change
every last program) just popped that cork -- a user emailed me
a bug that showed up when he recompiled on Centos 6, whereas
it had worked fine on 5.4. I tracked the bug down to this kind of
strcpy() and fixed it with an equivalent memmove().
Okay, fine. But now I'm re-wondering what's going on.
As a former IBM bal assembly programmer, and also Data General
assembly programmer, I can't think of any multiple byte block move
type of instruction that operates in an out-of-address order.
So what is a compiler/optimizer "thinking" that leads it to
generate machine code that operates in some out-of-address order
in this kind of situation? Got an example where it actually
makes any sense to do things that way? Thanks,
you all convinced me strcpy(s,s+n) is a really bad idea, and
I indeed changed code accordingly. Of course, I was always aware
it's formally wrong, but also aware it usually works just fine.
Unfortunately, some unchanged code (I couldn't go back and change
every last program) just popped that cork -- a user emailed me
a bug that showed up when he recompiled on Centos 6, whereas
it had worked fine on 5.4. I tracked the bug down to this kind of
strcpy() and fixed it with an equivalent memmove().
Okay, fine. But now I'm re-wondering what's going on.
As a former IBM bal assembly programmer, and also Data General
assembly programmer, I can't think of any multiple byte block move
type of instruction that operates in an out-of-address order.
So what is a compiler/optimizer "thinking" that leads it to
generate machine code that operates in some out-of-address order
in this kind of situation? Got an example where it actually
makes any sense to do things that way? Thanks,