This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: IMA vs tree-ssa
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Neil Booth <neil at daikokuya dot co dot uk>, Geoff Keating <geoffk at geoffk dot org>, Richard Henderson <rth at redhat dot com>, GCC List <gcc at gcc dot gnu dot org>
- Date: 08 Mar 2004 23:57:00 +0100
- Subject: Re: IMA vs tree-ssa
- Organization: Integrable Solutions
- References: <F0209661-68A9-11D8-8C0E-000A95D7CD40@apple.com><20040226230842.GA28463@redhat.com> <jmwu698lfu.fsf@desire.geoffk.org><20040227211712.GB16448@daikokuya.co.uk><jmoerk8ae8.fsf@desire.geoffk.org><20040227220212.GC16448@daikokuya.co.uk><404CF3C5.4070803@codesourcery.com>
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