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: g++ and aliasing bools


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...)


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