This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: working around "QImode can alias everything" missed optimizations


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]