Skip site navigation (1) Skip section navigation (2)

Re: fix memcpy() overlap

From: Michael van Elst <mlelstv(at)serpens(dot)de>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Neil Conway <neilc(at)samurai(dot)com>,PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: fix memcpy() overlap
Date: 2004-02-02 22:19:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
On Mon, Feb 02, 2004 at 01:23:15PM -0800, Stephan Szabo wrote:
> Isn't memcpy on overlapping (even entirely overlapping) buffers undefined
> behavior unless the count is 0?

The C standard says: "If copying takes place between objects that overlap,
the behaviour is undefined". SUSv3 says the same.

To my understanding this also includes copying something onto itself.

                                Michael van Elst
Internet: mlelstv(at)serpens(dot)de
                                "A potential Snark may lurk in every tree."

In response to

pgsql-patches by date

Next:From: Kurt RoeckxDate: 2004-02-02 22:22:47
Subject: Fix memcmp() with different sizes.
Previous:From: Andrew DunstanDate: 2004-02-02 22:18:08
Subject: Re: fix memcpy() overlap

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group