Zsh Mailing List Archive
Messages sorted by:
Re: "type punned" warnings
- X-seq: zsh-workers 22331
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: "type punned" warnings
- Date: Tue, 7 Mar 2006 11:48:47 -0800
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <200602282351.k1SNpqYb015731@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <schaefer@xxxxxxxxxxxxxxxx> <060228104557.ZM19739@xxxxxxxxxxxxxxxxxxxxxx> <200602282351.k1SNpqYb015731@xxxxxxxxxxxxxxxxx>
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:
There were two classes of warnings:
1. Multiple structure pointers were being cast to a HashNode (struct
2. A LinkList (struct linklist *) was being cast to a LinkNode (struct
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.
Messages sorted by: