From owner-freebsd-toolchain@FreeBSD.ORG Sun Dec 30 20:04:05 2012 Return-Path: Delivered-To: toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DB12CE9E; Sun, 30 Dec 2012 20:04:05 +0000 (UTC) (envelope-from db@db.net) Received: from diana.db.net (unknown [IPv6:2620:64:0:1:223:7dff:fea2:c8f2]) by mx1.freebsd.org (Postfix) with ESMTP id B60928FC0A; Sun, 30 Dec 2012 20:04:05 +0000 (UTC) Received: from night.db.net (localhost [127.0.0.1]) by diana.db.net (Postfix) with ESMTP id 679872AA46B; Sun, 30 Dec 2012 13:04:02 -0700 (MST) Received: by night.db.net (Postfix, from userid 1000) id 550AF1CC1B; Sun, 30 Dec 2012 15:03:14 -0500 (EST) Date: Sun, 30 Dec 2012 15:03:14 -0500 From: Diane Bruce To: Christoph Mallon Subject: Re: Fwd: Re: Bug in r244780 Message-ID: <20121230200314.GA35356@night.db.net> References: <20121229150648.GB66011@ithaqua.etoilebsd.net> <20121229160219.GA14487@night.db.net> <50DF41BE.9020206@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50DF41BE.9020206@gmx.de> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: toolchain@FreeBSD.org, Baptiste Daroussin X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Dec 2012 20:04:05 -0000 On Sat, Dec 29, 2012 at 08:17:18PM +0100, Christoph Mallon wrote: > On 29.12.2012 17:02, Diane Bruce wrote: > >> /* Create new group and copy old group into it. */ > >> - if ((newgr = malloc(len)) == NULL) > >> + if ((dst = malloc(len)) == NULL) > >> return (NULL); > >> + newgr = (struct group*)dst; > > > > Unfortunately the new compiler (clang) will error out on this. It's > > really anal. The error will be that it cannot convert char * alignment > > to struct group * alignment. 1 vs. 4 (or 8). BTDT > > This sounds like a bug. > First, it should not be an error, but at most a warning. Please take this up with toolchain@FreeBSD.org > Second, the cast is fine, as the pointer itself is a result of malloc(). > Obviously clang only checks the type of the variable. > Probably, the diagnostic can be suppressed with an intermediate cast to void*. > Third, the other casts (newgr + 1 casted to a char** and so on) are borderline invalid due to strict aliasing rules. > Therefore I prefer my method of chopping off bytes of a char buffer instead of munging differently typed pointers. > > Christoph - Diane -- - db@FreeBSD.org db@db.net http://www.db.net/~db