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

Re: Strict-aliasing warnings



On Thu, Feb 19, 2004 at 10:33:32AM +0000, Peter Stephenson wrote:
> The warning is highly obscure but my guess is it's worried because it
> doesn't know that the type we're looking at really does look like a
> HashNode.

Kind of, but only in the context of modern aliasing restrictions.  If
two aliases for a single memory location differ in type in a radical
enough manner, the compiler does not have to consider that the two
different references might affect one another.  E.g. you could change a
variable from one pointer and not have that change get reflected in the
reading from another pointer (or the original variable) because the
compiler might have optimized away the memory-fetch.  However, certain
casts force the compiler to be less aggressive in its optimizations
(such as (char *) and (void *)).

That is the intent of using the (void *) cast -- it _should_ let the
optimizer know that that variable needs to be refetched.  However, I'm
not 100% sure that this is enough to make sure that the optimizations
are valid or if it's only enough to just silence the warnings.

..wayne..



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