This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: working around "QImode can alias everything" missed optimizations
- To: egcs at tantalophile dot demon dot co dot uk
- Subject: Re: working around "QImode can alias everything" missed optimizations
- From: Mike Stump <mrs at windriver dot com>
- Date: Wed, 31 May 2000 12:30:01 -0700 (PDT)
- Cc: dje at transmeta dot com, gcc at gcc dot gnu dot org, rth at cygnus dot com
> Date: Wed, 31 May 2000 20:32:03 +0200
> From: Jamie Lokier <egcs@tantalophile.demon.co.uk>
> Mike Stump wrote:
> > > Is it possible to use an anonymous struct containing a char?
> >
> > No.
> <raises eyebrow>
Welcoe to C/C++.
> Why not? I thought a `struct X { int_type y; }'
int_type != char.
> would not type-alias anything except certain struct types related to
> X.
If you think it will work, show us the code, and I can try and cite
the rules. I'll start you off:
struct X { char x; } a, b;
int main() {
char *cp = &a.x;
*cp = 1;
a.x = 2;
a = b;
}
Think about that can alias what under the ANSI rules. The _point_ of
the exercise was to avoid aliasing, just in case you forget. Be sure
to read and understand:
[#7] An object shall have its stored value accessed only by
an lvalue expression that has one of the following types:59
- 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.
Anyway, all of this discussion is pointless anyway, as I already
mentioned a more direct solution to the problem.