This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: subreg question
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Dale Johannesen <dalej at apple dot com>
- Cc: Daniel Jacobowitz <drow at mvista dot com>, gcc external <gcc at gcc dot gnu dot org>
- Date: 13 Dec 2001 13:35:04 -0800
- Subject: Re: subreg question
- References: <EEBA8D7B-F00C-11D5-86F6-003065C86F94@apple.com>
On Thu, 2001-12-13 at 13:04, Dale Johannesen wrote:
>
> On Thursday, December 13, 2001, at 12:43 PM, Daniel Jacobowitz wrote:
> >>>>
> >>>> I don't see why not. (C89) 3.3.4 says the cast might produce an
> >>>> invalid
> >>>> pointer if it's not aligned properly, which is not the case here.
> >>>> Other than that I don't find any relevant restriction in the standard.
> >>>> What did you have in mind?
> >>>> (FWIW, gcc doesn't warn about this even with -pedantic.)
> >>>
> >>> It's not an invalid pointer. It doesn't alias with Z, though.
> >>
> >> Why not?
> >
> > The C standard's aliasing rules. *((float *)&z) is an object of type
> > float; double is a different type than float; z is an object of type
> > double; *((float *)&z) and z can not alias.
>
> Can you point me to someplace in the standard that says this?
i am NOT a language lawyer, as most of my patches can show :))
but i think this is it:
7 An object shall have its stored value accessed only by an lvalue
expression that has one of the following types:73) [The intent of
this list is to specify those circumstances in which an object may
or may not be aliased.] 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.