Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Strict-aliasing warnings



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..
--- 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);
 	}
 }
 


Messages sorted by: Reverse Date, Date, Thread, Author