This is the mail archive of the
mailing list for the GCC project.
Re: [C++ PATCH] Fix aliasing warnings for typeid (PR c++/32260)
On 11/1/07, Jakub Jelinek <firstname.lastname@example.org> wrote:
> 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
Ah, I see.
> I could perhaps add some static bool variable, so that this would be done
> only once. But is it worth it?
+ if (! TYPE_ALIAS_SET_KNOWN_P (pseudo_type_info))
+ tree type_info_type = TYPE_MAIN_VARIANT (const_type_info_type_node);
+ TYPE_ALIAS_SET (pseudo_type_info) = get_alias_set (type_info_type);
gcc_assert (TYPE_ALIAS_SET (pseudo_type_info) == get_alias_set
I think it's worth it for checking purposes.