Liste des Groupes | Revenir à c arch |
Michael S wrote:On Mon, 02 Sep 2024 06:59:32 -0700
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
mitchalsup@aol.com (MitchAlsup1) writes:
On Mon, 2 Sep 2024 5:55:34 +0000, Thomas Koenig wrote:>
George Neuner <gneuner2@comcast.net> schrieb:>
I'm not going to argue about whether UB in code is wrong. The>
question I have concerns what to do with something that
explicitly is mentioned as UB in some standard N, but was not
addressed in previous standards.
>
Was it always UB? Or should it be considered ID until it became
UB?
Can you give an exapmple?
Memcopy() with overlapping pointers.
Calling memcpy() between objects that overlap has always been
explicitly and specifically undefined behavior, going back to
the original ANSI C standard.
3 years ago Terje Mathisen wrote that many years ago he read that
behaviour of memcpy() with overlappped src/dst was defined.
https://groups.google.com/g/comp.arch/c/rSk8c7Urd_Y/m/ZWEG5V1KAQAJ
Mitch Alsup answered "That was true in 1983".
So, two people of different age living in different parts of the
world are telling the same story. May be, there exist old popular
book that said that it was defined?
It probably wasn't written in the official C standard, which I
couldn't have afforded to buy/read, but in a compiler runtime doc?
Specifying that it would always copy from beginning to end of the
source buffer, in increasing address order meant that it was
guaranteed safe when used to compact buffers.
>
Code that depended on this was fine for decades, until the first
library/compiler implementation discovered that in some circumstances
it could be faster to go in reverse order.
Terje
Les messages affichés proviennent d'usenet.