zsh-workers
 help / color / mirror / code / Atom feed
* Q: do we want the void* patch?
@ 2004-03-01 21:36 Wayne Davison
  2004-03-02  2:44 ` Anthony Heading
  0 siblings, 1 reply; 2+ messages in thread
From: Wayne Davison @ 2004-03-01 21:36 UTC (permalink / raw)
  To: zsh-workers

To revisit my patch in zsh-workers/19445, I didn't get a response to my
last query asking if we want to include it.  Was the consensus that we
don't need it?  I think that including it would help us to ensure that
the optimizer doesn't over-optimize certain aliased memory locations.

..wayne..


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Q: do we want the void* patch?
  2004-03-01 21:36 Q: do we want the void* patch? Wayne Davison
@ 2004-03-02  2:44 ` Anthony Heading
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Heading @ 2004-03-02  2:44 UTC (permalink / raw)
  To: Wayne Davison; +Cc: zsh-workers


On Mon, Mar 01, 2004 at 01:36:24PM -0800, Wayne Davison wrote:
> To revisit my patch in zsh-workers/19445, I didn't get a response to my
> last query asking if we want to include it.  Was the consensus that we
> don't need it?  I think that including it would help us to ensure that
> the optimizer doesn't over-optimize certain aliased memory locations.

Umm, the consensus seemed to be that it made the warnings go away, but
that nobody is sure whether it's really fixing a problem.

You said in an earlier message:

> However, certain casts force the compiler to be less aggressive in
> its optimizations (such as (char *) and (void *)).

Why do you think that void * is special?

Reading http://mail-index.netbsd.org/tech-kern/2003/08/11/0001.html
which contains this bit from the standard:

% 7 An object shall have its stored value accessed only by an lvalue
%   expression that has one of the following types: {footnote 73}
%
%     a type compatible with the effective type of the object,
%
%     a qualified version of a type compatible with the effective type of
%     the object,
%
%     a type that is the signed or unsigned type corresponding to the
%     effective type of the object,
%
%     a type that is the signed or unsigned type corresponding to a
%     qualified version of the effective type of the object,
%
%     an aggregate or union type that includes one of the aforementioned
%     types among its members (including, recursively, a member of a
%     subaggregate or contained union), or
%
%     a character type.

Doesn't this suggest one can only use char *?

And as Peter said, does the cast really fix the problem or just
make it worse?  

One of the corresponding fixes in glibc - I guess we can assume
those guys know what they're doing, looks like

-	querybuf *buf, *origbuf;
+	union
+	{
+	  querybuf *buf;
+	  u_char *ptr;
+	} buf;
+	querybuf *origbuf;

i.e. using a union type to ensure that aliasing is ok. Didn't
seem as simple for them as just casting to void *.

Maybe that's what is necessary throughout zsh?  Would raise the
question of why to bother though - how many compilers won't have
an option to turn off the ISO aliasing rules?

Perl, for example, uses no-strict-aliasing, so it's not
like zsh would be alone.  Nor is zsh really in pursuit of
fortran's array performance, which is really the whole reason
behind this aliasing tedium.

And the damage done to code readability in casting things to
void * isn't to be taken lightly...

Anthony




This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data 
and other information are not warranted as to completeness or accuracy and 
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan Chase & Co., its
subsidiaries and affiliates.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-03-02  2:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-01 21:36 Q: do we want the void* patch? Wayne Davison
2004-03-02  2:44 ` Anthony Heading

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