Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VarHh-0006av-7y for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Oct 2013 18:11:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VarHg-0001Jt-N9 for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Oct 2013 18:11:24 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VarHe-0001HG-4V for pgsql-hackers@postgresql.org; Mon, 28 Oct 2013 18:11:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VarHb-00060Q-8x for pgsql-hackers@postgresql.org; Mon, 28 Oct 2013 18:11:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id r9SIBCOS007719; Mon, 28 Oct 2013 14:11:12 -0400 From: Tom Lane To: Robert Haas cc: Andres Freund , "pgsql-hackers@postgresql.org" , Matthias Schmitt Subject: Re: OSX doesn't accept identical source/target for strcpy() anymore In-reply-to: References: <5A871654-B250-4837-99DB-EB6D44E64E65@mmp.lu> <20131028144225.GG5577@awork2.anarazel.de> <55D64809-F305-41A9-946B-8EAFF88FBE3B@mmp.lu> <20131028153750.GH5577@awork2.anarazel.de> <934199A3-FF2F-4E5E-A8FF-E6F621B6F64D@mmp.lu> <20131028161132.GA14980@awork2.anarazel.de> Comments: In-reply-to Robert Haas message dated "Mon, 28 Oct 2013 12:31:26 -0400" Date: Mon, 28 Oct 2013 14:11:12 -0400 Message-ID: <7718.1382983872@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Robert Haas writes: > On Mon, Oct 28, 2013 at 12:11 PM, Andres Freund wrote: >> There have been previous discussions about fixing strcpy calls with >> identical source/destination (same for memcpy) but it was deemed not >> worth the effort. I don't really see an alternative to fixing it now. > Ugh. Why in the world would Apple break this? It's broken already; the C and POSIX standards say of strncpy: If copying takes place between objects that overlap, the behavior is undefined. Both gcc and glibc have been moving steadily in the direction of aggressively exploiting "undefined behavior" cases for optimization purposes. I don't know if there is yet a platform where strncpy with src == dest behaves oddly, but we'd be foolish to imagine that it's not going to happen eventually. If anything, Apple is probably doing us a service by making it obvious where we're failing to adhere to spec. However ... I still can't replicate this here, and as you say, there's about zero chance of keeping our code clean of this problem unless we can set up a buildfarm member that will catch it. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers