From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11684 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Documentation of memcpy and undefined behavior in memset Date: Thu, 6 Jul 2017 14:13:26 -0400 Message-ID: <20170706181326.GF1627@brightrain.aerifal.cx> References: <0F9B48AD-C5B3-44B6-8D82-0985CF8604A0@trust-in-soft.com> <20170706162353.GC1627@brightrain.aerifal.cx> <20170706171101.GD1627@brightrain.aerifal.cx> <20170706172218.GE1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1499364823 12640 195.159.176.226 (6 Jul 2017 18:13:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 6 Jul 2017 18:13:43 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11697-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jul 06 20:13:40 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dTBHU-0002uV-Dk for gllmg-musl@m.gmane.org; Thu, 06 Jul 2017 20:13:36 +0200 Original-Received: (qmail 4075 invoked by uid 550); 6 Jul 2017 18:13:38 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 4046 invoked from network); 6 Jul 2017 18:13:38 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11684 Archived-At: On Thu, Jul 06, 2017 at 08:38:29PM +0300, Alexander Monakov wrote: > On Thu, 6 Jul 2017, Rich Felker wrote: > > > I'm doubtful of this. Certainly passing a pointer to memcpy with a > > nonzero n is a guarantee that the pointed-to object is non-volatile. > > The n=0 case is less clear though. > > My view is that since in n=0 case no memory access inside of memcpy > takes place, the compiler may not deduce that the pointed-to object is > ok for speculative reads. Indeed, I think that's a valid interpretation, but not the only one; the problem here is that the specification is ambiguous, and I suspect nobody wants to fix the ambiguity because they know they're going to have an argument over what it was intended to mean... Rich