This is the mail archive of the gcc-patches@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: [C++ PATCH] Fix aliasing warnings for typeid (PR c++/32260)


On Thu, Nov 01, 2007 at 01:53:46PM +0100, Richard Guenther wrote:
> The comment hints at that this should be
> 
>        gcc_assert (! TYPE_ALIAS_SET_KNOWN_P (pseudo_type_info));
> 
> or does this break at any time?

Sure, typeid_ok_p is called many times (once for each typeid parsed
at least) and once we set it it will be TYPE_ALIAS_SET_KNOWN_P
(pseudo_type_info).

I could perhaps add some static bool variable, so that this would be done
only once.  But is it worth it?

  static bool typeid_ok_p_called = false;
  tree type_info_type;

and:

  if (typeid_ok_p_called)
    return true;
  typeid_ok_p_called = true;

  pseudo_type_info
    = VEC_index (tinfo_s, tinfo_descs, TK_TYPE_INFO_TYPE)->type;

  gcc_assert (! TYPE_ALIAS_SET_KNOWN_P (pseudo_type_info));

  /* Make sure abi::__type_info_pseudo has the same alias set
     as std::type_info.  */
  type_info_type = TYPE_MAIN_VARIANT (const_type_info_type_node);
  TYPE_ALIAS_SET (pseudo_type_info) = get_alias_set (type_info_type);

	Jakub


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