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: IMA vs tree-ssa


Mark Mitchell <mark@codesourcery.com> writes:

| Neil Booth wrote:
| 
| >Geoff Keating wrote:-
| >
| >
| >>In any case, it's still not transitive, because 'bar' in:
| >>
| >>struct foo;
| >> struct bar {  struct foo *f;
| >>};
| >>
| >>is compatible with
| >>
| >>struct foo { int a; };
| >> struct bar {  struct foo *f;
| >>};
| >>
| >>and
| >>
| >>struct foo { int b; };
| >> struct bar {  struct foo *f;
| >>};
| >>
| >>but they are not compatible with each other.
| >>
| Has anyone asked the C committee what they think about this?
| 
| I strongly expect that their intention was to create a requirement
| that compatibility be an equivalence relation.  Certainly, there's no
| reason to suspect that passing pointers to "struct foo" from the
| second to third translation unit above would work, at least if the two
| "struct foo" objects were not themselves so similar.  I would expect
| that this is a defect in the standard.

I suspect your C++ brackground is showing up :-)

I believe Neil is right. See 

    6.2.7  Compatible type and composite type
       [#1] Two types have compatible type if their types  are  the
       same.   Additional  rules  for determining whether two types
       are compatible are described in 6.7.2 for  type  specifiers,
       in   6.7.3   for   type   qualifiers,   and   in  6.7.5  for
       declarators.46)   Moreover,   two   structure,   union,   or
       enumerated  types declared in separate translation units are
       compatible if their tags and members satisfy  the  following
       requirements:   If  one  is  declared  with a tag, the other
       shall be declared with the same tag.  If both  are  complete
       types,  then  the  following  additional requirements apply:
       there shall be a  one-to-one  correspondence  between  their
       members  such  that  each  pair of corresponding members are
       declared with compatible types, and such that if one  member
       of  a  corresponding pair is declared with a name, the other
       member is declared with the same name.  For two  structures,
       corresponding  members  shall be declared in the same order.
       For two structures or unions, corresponding bit-fields shall
       have  the  same widths.  For two enumerations, corresponding
       members shall have the same values.

       [#2] All declarations that  refer  to  the  same  object  or
       function shall have compatible type; otherwise, the behavior
       is undefined.

       [#3] A composite type can be constructed from two types that
       are compatible; it is a type that is compatible with both of
       the two types and satisfies the following conditions:

         -- If one type is an array of  known  constant  size,  the
            composite  type is an array of that size; otherwise, if
            one type is a variable length array, the composite type
            is that type.

         -- If  only  one  type is a function type with a parameter
            type list (a function prototype), the composite type is
            a function prototype with the parameter type list.

         -- If  both  types  are function types with parameter type
            lists, the type of  each  parameter  in  the  composite
            parameter  type  list  is  the  composite  type  of the
            corresponding parameters.

       These rules apply recursively to the types  from  which  the
       two types are derived.



from the C standard.

Or course, in C++, that is ODR violation.

-- Gaby


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