g++ and aliasing bools
Dan Nicolaescu
dann@ics.uci.edu
Thu Jan 24 15:18:00 GMT 2002
Mark Mitchell <mark@codesourcery.com> writes:
> > Can the AGGREGATE_TYPE_P check be relaxed for classes that don't have
> > a base class?
>
> Maybe, but it needs careful thought. "It makes sense" isn't good enough;
> we need a proof that this is safe. Such a proof needs to take into
> account that other classes may be derived (possibly indirectly or
> virtually) from the simple class.
Currently cxx_get_alias_set looks like:
{
if (AGGREGATE_TYPE_P (t))
return 0;
return c_common_get_alias_set (t);
}
An incremental improvement would be to allow at least C-type structs.
{
if (AGGREGATE_TYPE_P (t) &&
IS_A_CLASS_DERIVED_FROM_ANOTHER_CLASS_P (t)) /* [1] */
return 0;
return c_common_get_alias_set (t);
}
should be safe because:
a) the predicate [1] is true for any aggregate that is not a C-type struct
b) c_common_get_alias_set deals with C-type structs correctly
c) C-type structs cannot alias derived classes because the later are
put in alias set 0 because of [1]
Is this acceptable?
I don't know how the
IS_A_CLASS_DERIVED_FROM_ANOTHER_CLASS_P predicate should be written.
I tried using:
CLASSTYPE_N_BASECLASSES (t)
but that does not seem to be enough (I don't know much about the C++
frontend...)
More information about the Gcc
mailing list