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]
Other format: [Raw text]

Re: [RFC] ignoring type alias conflicts between structures and scalars


    Jeff's argument is that it's not really possible for a pointer to a
    structure to point to a scalar variable.  If the structure is not type
    compatible with the scalar, then they can't alias.  That makes some
    sense to me.

    However, the front end says that those two types are alias compatible,
    meaning that we could store into X via x.  So, I'm confused.  

The reason is because the compatible relation is reflexive.  A pointer to an
integer could alias the structure because the integer field is addressable.

Note that the flag DECL_NONADDRESSABLE_P exists for those languages where
there is a way to indicate that taking the address of a component of a
structure is not allowed.  In that case, the two types don't conflict.

    I'm also attaching a program that breaks this patch.  Basically, it
    causes 'bar()' to return &X.

But that breakage is OK because the pointer-punning cast is supposed to be
incompatible with -fstrict-aliasing.

    If the program isn't well defined, why is alias_sets_conflict_p() saying
    that 'struct int_float_s' and 'int' have conflicting alias sets?

As I said above, because a pointer to "int" can conflict with an operation
that references all of int_float_s since the int pointer could be pointing
into an occurence of int_float_s.


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