Date: Sun, 30 Dec 2012 15:03:14 -0500 From: Diane Bruce <db@db.net> To: Christoph Mallon <christoph.mallon@gmx.de> Cc: toolchain@FreeBSD.org, Baptiste Daroussin <bapt@FreeBSD.org> Subject: Re: Fwd: Re: Bug in r244780 Message-ID: <20121230200314.GA35356@night.db.net> In-Reply-To: <50DF41BE.9020206@gmx.de> References: <20121229150648.GB66011@ithaqua.etoilebsd.net> <20121229160219.GA14487@night.db.net> <50DF41BE.9020206@gmx.de>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121230200314.GA35356>