From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14703 invoked from network); 7 Mar 2006 19:49:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 7 Mar 2006 19:49:04 -0000 Received: (qmail 45539 invoked from network); 7 Mar 2006 19:48:55 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 7 Mar 2006 19:48:55 -0000 Received: (qmail 29381 invoked by alias); 7 Mar 2006 19:48:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22331 Received: (qmail 29372 invoked from network); 7 Mar 2006 19:48:51 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 7 Mar 2006 19:48:51 -0000 Received: (qmail 45194 invoked from network); 7 Mar 2006 19:48:51 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 7 Mar 2006 19:48:50 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id E76756D9; Tue, 7 Mar 2006 11:48:47 -0800 (PST) Date: Tue, 7 Mar 2006 11:48:47 -0800 From: Wayne Davison To: Peter Stephenson Cc: zsh-workers@sunsite.dk Subject: Re: "type punned" warnings Message-ID: <20060307194847.GC28589@dot.blorf.net> References: <060228104557.ZM19739@torch.brasslantern.com> <200602282351.k1SNpqYb015731@pwslaptop.csr.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200602282351.k1SNpqYb015731@pwslaptop.csr.com> User-Agent: Mutt/1.5.11+cvs20060126 On Tue, Feb 28, 2006 at 11:51:52PM +0000, Peter Stephenson wrote: > We've been getting these from gcc 3+ for a while. I think Wayne > suggested some casts to void * would be enough to remove them. Yeah, that was a pretty ugly kluge of dubious usefulness. I've created a patch that fixes the aliasing at a fundamental level. It's really big, so I'll provide a link instead of attaching it: http://opencoder.net/punning.diff There were two classes of warnings: 1. Multiple structure pointers were being cast to a HashNode (struct hashnode *). 2. A LinkList (struct linklist *) was being cast to a LinkNode (struct linknode *). I fixed the first class of warnings by putting a "struct hashnode node;" at the start of every structure that was getting cast to HashNode. This required sprinkling some "node." prefixes around the code for the three affected structure variables (next, nam, and flags). I fixed the second class of warnings by making a LinkList a union of a "struct linklist list;" and a "struct linknode node;". This tells the compiler that the type punning between the two pointer classes needs to be taken into account when optimizing. This required sprinkling some "list." prefixes around the code and referring to the "node" when appropriate. I also added an "int flag" to the linklist structure, since it now fits in the union (which an uncommitted patch of mine will like having around). I also think that it would be nice to rename the "last" variable in the LinkNode structure to be "prev", which is a clearer name to me. I didn't do that (at least, not yet) because it would just clutter up an already huge patch. ..wayne..