This is the mail archive of the gcc-patches@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: aliasing warnings [patch]


>>>>> "Richard" == Richard Henderson <rth@cygnus.com> writes:

    Richard> On Thu, Sep 16, 1999 at 01:07:52PM -0700, Mark Mitchell
    Richard> wrote:
    >> The underlying type of the fields is `char' and you're putting
    >> `int' into them.  That's no different than:
    >> 
    >> char c[4]; *((int *) &c[0]) = 3;

    Richard> Modulo the alignment argument, isn't this really ok?
    Richard> True, the variable has `char' type, but the storage is
    Richard> only accessed as `int'.

I don't think GCC will generate bad code in this case, because of what
you say.  (There's no aliasing issue if all rferences are through the
`int *'.)  But, I don't think this is conforming ISO C.  The dynamic
type of the object is `char ()[4]', while the lvalue is of type `int'.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


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