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: Clarification anyone? -- was Re: Linux and aliasing?


>>>>> "george" == george  <george@moberg.com> writes:

    george> I've been following this thread from the beginning, but I
    george> don't have the ANSI/ISO standard for C, and I'd like to
    george> know more about what kind of code is conformant and what
    george> isn't.

It's pretty simple: you may only access something of type X through an
lvalue of type X (i.e., a pointer of type X*, or a variable of type X,
or some such.)  The exceptions are that you may access *anything*
though a pointer of type `char*', and that you may use a `const X*' to
access a non-const X, or an `X*' to access a `const X' (similarly for
volatile).  Also, you can use `signed int*' to access an `unsigned
int'; similarly for other integer types.

    george> This whole thing seems a little scary--I'm using egcs
    george> 1.1.2 on a large project and I'd be afraid to upgrade
    george> without a clear understanding of this particular issue
    george> and/or a clear warning from the compiler when I violate
    george> the aliasing rules, whether I violate them on purpose or
    george> by accident.

Just turn on -fno-strict-aliasing; that's the same behavior you know
and love.

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