From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13302 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: un-UBify-strings Date: Sat, 22 Sep 2018 22:45:11 -0400 Message-ID: <20180923024511.GF17995@brightrain.aerifal.cx> References: <20180923003542.GC17995@brightrain.aerifal.cx> <20180923023234.GE17995@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 1537670599 31108 195.159.176.226 (23 Sep 2018 02:43:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Sep 2018 02:43:19 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-13318-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 23 04:43:15 2018 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 1g3uMc-0007zm-DC for gllmg-musl@m.gmane.org; Sun, 23 Sep 2018 04:43:14 +0200 Original-Received: (qmail 32324 invoked by uid 550); 23 Sep 2018 02:45:23 -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 32303 invoked from network); 23 Sep 2018 02:45:23 -0000 Content-Disposition: inline In-Reply-To: <20180923023234.GE17995@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13302 Archived-At: On Sat, Sep 22, 2018 at 10:32:34PM -0400, Rich Felker wrote: > On Sun, Sep 23, 2018 at 02:11:42AM +0000, Pascal Cuoq wrote: > > Hello Rich, > > > > On 23 Sep 2018, at 02:35, Rich Felker > wrote: > > > > I've had this patch sitting around since 2016, and just updated it to > > apply cleanly. Any objections? > > > > Your patch contains: > > > > .... > > size_t __attribute__((__may_alias__)) *wd; > > const size_t __attribute__((__may_alias__)) *ws; > > .... > > > > In my experience, this use of __may_alias__ does not do anything. > > See function f in the example below, which both GCC and Clang > > optimize as if the programmer had not used __may_alias__ at all: > > https://gcc.godbolt.org/z/Um4NU7 > > > > You should use a typdef for the aliasing type, as shown for function > > g (in with GCC and Clang do not apply the optimization). > > > > The example in GCC's documentation for __may_alias__ also uses a > > typedef: > > https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Type-Attributes.html > > Thanks, this is very helpful. I'll prepare an updated version. While I've got your attention, I'm also trying to fix the UB in address range checks for implementing memmove as memcpy, etc. Is this correct: if ((uintptr_t)s-(uintptr_t)d-n <= -2*n) return memcpy(d, s, n); ? Rich