Deutsch English Français Italiano |
<86y141js89.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch <tr.17687@z991.linuxsc.com> Newsgroups: comp.arch Subject: Re: Computer architects leaving Intel... Date: Sun, 08 Sep 2024 22:44:54 -0700 Organization: A noiseless patient Spider Lines: 46 Message-ID: <86y141js89.fsf@linuxsc.com> References: <vaqgtl$3526$1@dont-email.me> <memo.20240830090549.19028u@jgd.cix.co.uk> <2024Aug30.161204@mips.complang.tuwien.ac.at> <86r09ulqyp.fsf@linuxsc.com> <2024Sep8.173639@mips.complang.tuwien.ac.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Mon, 09 Sep 2024 07:45:01 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2550a8cb929efdfde26bde1f2c6c70c6"; logging-data="2431635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VvW96/Dty5UEnqa3iGzF3hBnYzv46aCo=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:SnkUO4iJn+IvP12Xr4+zQ+jBE0o= sha1:2dlD1Ke/Fm5nLCAsg6Ln8lR1Mrc= Bytes: 3095 anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: > Tim Rentsch <tr.17687@z991.linuxsc.com> writes: > >> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: >> >>> There was still no easy way to determine whether your software >>> that calls memcpy() actually works as expected on all hardware, >> >> There may not be a way to tell if memcpy()-calling code will work >> on platforms one doesn't have, but there is a relatively simple >> and portable way to tell if some memcpy() call crosses over into >> the realm of undefined behavior. > > 1) At first I thought that yes, one could just check whether there > is an overlap of the memory areas. But then I remembered that you > cannot write such a check in standard C without (in the general > case) exercising undefined behaviour; Yes, I can. > and then the compiler could eliminate the check or do something > else that's unexpected. Do you have such a check in mind that > does not exercise undefined behaviour in the general case? Sure. I wouldn't have made my earlier statement otherwise. > 2) Even if there is such a check, you have to be aware that there > is a potential problem with memcpy(). In that case the way to go > is to just use memmove(). The point of my previous comment was only to address the question of whether any existing memcpy() calls are problematic. If all of the checks return "no overlap" then memcpy() is not the problem. That said, using memmove() in place of memcpy() is one way to get around problems with undesired behavior from memcpy(), but depending on circumstances there may be other ways that are better. > But that does not help you with the next "clever" idea that some > compiler or library maintainer has. I have the impression that this is an editorial comment having nothing to do with memcpy() or memmove(). If that impression is wrong then I'm at a loss to understand what you are talking about, and would you please elaborate.