zsh-workers
 help / color / mirror / code / Atom feed
From: Wayne Davison <wayned@users.sourceforge.net>
To: zsh-workers@sunsite.dk
Subject: Strict-aliasing warnings
Date: Thu, 19 Feb 2004 02:20:29 -0800	[thread overview]
Message-ID: <20040219102029.GB26450@blorf.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 290 bytes --]

I'm using a version of gcc 3.3 to compile zsh, and it is spitting out a
bunch of warnings like this:

warning: dereferencing type-punned pointer will break strict-aliasing rules

The attached patch silences these warnings, but I'm not sure if this is
the right way to fix these.

..wayne..

[-- Attachment #2: zsh-aliasing.patch --]
[-- Type: text/plain, Size: 5806 bytes --]

--- Src/exec.c	13 Nov 2003 14:34:38 -0000	1.57
+++ Src/exec.c	19 Feb 2004 09:46:55 -0000
@@ -1844,7 +1844,7 @@ execcmd(Estate state, int input, int out
 			if (nextnode(firstnode(args)))
 			    next = (char *) getdata(nextnode(firstnode(args)));
 		    } else {
-			hn = (HashNode)&commandbn;
+			hn = (void *) &commandbn;
 			is_builtin = 1;
 			break;
 		    }
--- Src/utils.c	17 Dec 2003 20:47:39 -0000	1.57
+++ Src/utils.c	19 Feb 2004 09:46:56 -0000
@@ -509,7 +509,7 @@ finddir(char *s)
     strcpy(finddir_full, s);
     finddir_best=0;
     finddir_last=NULL;
-    finddir_scan((HashNode)&homenode, 0);
+    finddir_scan((void *) &homenode, 0);
     scanhashtable(nameddirtab, 0, 0, 0, finddir_scan, 0);
     return finddir_last;
 }
--- Src/zsh.h	15 Dec 2003 22:45:29 -0000	1.52
+++ Src/zsh.h	19 Feb 2004 09:46:57 -0000
@@ -371,7 +371,7 @@ struct linklist {
         (N).first = &__n0; \
         (N).last = &__n0; \
         __n0.next = NULL; \
-        __n0.last = (LinkNode) &(N); \
+        __n0.last = (void *) &(N); \
         __n0.dat = (void *) (V0); \
     } while (0)
 
--- Src/Modules/mapfile.c	11 Apr 2001 00:09:06 -0000	1.5
+++ Src/Modules/mapfile.c	19 Feb 2004 09:46:57 -0000
@@ -320,7 +320,7 @@ scanpmmapfile(HashTable ht, ScanFunc fun
 	 */
 	pm.nam = dupstring(pm.nam);
 	pm.u.str = "";
-	func((HashNode) &pm, flags);
+	func((void *) &pm, flags);
     }
     closedir(dir);
 }
--- Src/Modules/parameter.c	13 Nov 2003 14:34:38 -0000	1.28
+++ Src/Modules/parameter.c	19 Feb 2004 09:46:57 -0000
@@ -188,7 +188,7 @@ scanpmparameters(HashTable ht, ScanFunc 
 		((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
 		 !(flags & SCANPM_WANTKEYS)))
 		pm.u.str = paramtypestr((Param) hn);
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
 }
 
@@ -327,7 +327,7 @@ scanpmcommands(HashTable ht, ScanFunc fu
 		    strcat(pm.u.str, cmd->nam);
 		}
 	    }
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
 }
 
@@ -545,7 +545,7 @@ scanfunctions(HashTable ht, ScanFunc fun
 			zsfree(t);
 		    }
 		}
-		func((HashNode) &pm, flags);
+		func((void *) &pm, flags);
 	    }
 	}
 }
@@ -663,7 +663,7 @@ scanbuiltins(HashTable ht, ScanFunc func
 
 		    pm.u.str = dupstring(t);
 		}
-		func((HashNode) &pm, flags);
+		func((void *) &pm, flags);
 	    }
 	}
 }
@@ -835,7 +835,7 @@ scanpmoptions(HashTable ht, ScanFunc fun
 	    pm.nam = hn->nam;
 	    ison = optno < 0 ? !opts[-optno] : opts[optno];
 	    pm.u.str = dupstring(ison ? "on" : "off");
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
 }
 
@@ -965,7 +965,7 @@ scanpmmodules(HashTable ht, ScanFunc fun
 	    pm.u.str = ((m->flags & MOD_ALIAS) ?
 			dyncat("alias:", m->u.alias) : loaded);
 	    addlinknode(done, pm.nam);
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
     }
     pm.u.str = dupstring("autoloaded");
@@ -975,14 +975,14 @@ scanpmmodules(HashTable ht, ScanFunc fun
 		!findmodnode(done, ((Builtin) hn)->optstr)) {
 		pm.nam = ((Builtin) hn)->optstr;
 		addlinknode(done, pm.nam);
-		func((HashNode) &pm, flags);
+		func((void *) &pm, flags);
 	    }
 	}
     for (p = condtab; p; p = p->next)
 	if (p->module && !findmodnode(done, p->module)) {
 	    pm.nam = p->module;
 	    addlinknode(done, pm.nam);
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
     for (i = 0; i < realparamtab->hsize; i++)
 	for (hn = realparamtab->nodes[i]; hn; hn = hn->next) {
@@ -990,7 +990,7 @@ scanpmmodules(HashTable ht, ScanFunc fun
 		!findmodnode(done, ((Param) hn)->u.str)) {
 		pm.nam = ((Param) hn)->u.str;
 		addlinknode(done, pm.nam);
-		func((HashNode) &pm, flags);
+		func((void *) &pm, flags);
 	    }
 	}
 }
@@ -1096,7 +1096,7 @@ scanpmhistory(HashTable ht, ScanFunc fun
 		!(flags & SCANPM_WANTKEYS))
 		pm.u.str = dupstring(he->text);
 	}
-	func((HashNode) &pm, flags);
+	func((void *) &pm, flags);
 
 	he = up_histent(he);
     }
@@ -1220,7 +1220,7 @@ scanpmjobtexts(HashTable ht, ScanFunc fu
 		    !(flags & SCANPM_WANTKEYS))
 		    pm.u.str = pmjobtext(job);
 	    }
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
     }
 }
@@ -1330,7 +1330,7 @@ scanpmjobstates(HashTable ht, ScanFunc f
 		    !(flags & SCANPM_WANTKEYS))
 		    pm.u.str = pmjobstate(job);
 	    }
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
     }
 }
@@ -1405,7 +1405,7 @@ scanpmjobdirs(HashTable ht, ScanFunc fun
 		   !(flags & SCANPM_WANTKEYS))
 		   pm.u.str = pmjobdir(job);
 	   }
-           func((HashNode) &pm, flags);
+           func((void *) &pm, flags);
        }
     }
 }
@@ -1540,7 +1540,7 @@ scanpmnameddirs(HashTable ht, ScanFunc f
 		    ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
 		     !(flags & SCANPM_WANTKEYS)))
 		    pm.u.str = dupstring(nd->dir);
-		func((HashNode) &pm, flags);
+		func((void *) &pm, flags);
 	    }
 	}
 }
@@ -1606,7 +1606,7 @@ scanpmuserdirs(HashTable ht, ScanFunc fu
 		    ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
 		     !(flags & SCANPM_WANTKEYS)))
 		    pm.u.str = dupstring(nd->dir);
-		func((HashNode) &pm, flags);
+		func((void *) &pm, flags);
 	    }
 	}
 }
@@ -1894,7 +1894,7 @@ scanaliases(HashTable alht, HashTable ht
 		    ((pmflags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
 		     !(pmflags & SCANPM_WANTKEYS)))
 		    pm.u.str = dupstring(al->text);
-		func((HashNode) &pm, pmflags);
+		func((void *) &pm, pmflags);
 	    }
 	}
 }
--- Src/Zle/zleparameter.c	31 May 2001 09:44:00 -0000	1.2
+++ Src/Zle/zleparameter.c	19 Feb 2004 09:46:57 -0000
@@ -147,7 +147,7 @@ scanpmwidgets(HashTable ht, ScanFunc fun
 		((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
 		 !(flags & SCANPM_WANTKEYS)))
 		pm.u.str = widgetstr(((Thingy) hn)->widget);
-	    func((HashNode) &pm, flags);
+	    func((void *) &pm, flags);
 	}
 }
 

             reply	other threads:[~2004-02-19 10:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-19 10:20 Wayne Davison [this message]
2004-02-19 10:33 ` Peter Stephenson
2004-02-19 10:50   ` Wayne Davison
2004-02-19 11:04     ` Peter Stephenson
2004-02-26  3:18       ` Wayne Davison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040219102029.GB26450@blorf.net \
    --to=wayned@users.sourceforge.net \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).