zsh-workers
 help / color / mirror / code / Atom feed
From: Anthony Heading <aheading@jpmorgan.com>
To: Wayne Davison <wayned@users.sourceforge.net>
Cc: zsh-workers@sunsite.dk
Subject: Re: Q: do we want the void* patch?
Date: Tue, 2 Mar 2004 11:44:48 +0900	[thread overview]
Message-ID: <20040302024448.GA27715@tkd-fires-02.ja.jpmorgan.com> (raw)
In-Reply-To: <20040301213624.GA18698@blorf.net>


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.



      reply	other threads:[~2004-03-02  2:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-01 21:36 Wayne Davison
2004-03-02  2:44 ` Anthony Heading [this message]

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=20040302024448.GA27715@tkd-fires-02.ja.jpmorgan.com \
    --to=aheading@jpmorgan.com \
    --cc=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).