This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GTY and const
Zack Weinberg <zack@codesourcery.com> writes:
> Matt Kraai <kraai@ftbfs.org> writes:
>
> > Howdy,
> >
> > One of the warnings that causes PR 18176 is an assignment of a const
> > cpp_token * to the source member of the val union of the cpp_token
> > structure, which is not const. According to the uses I've found, this
> > member could be const, except that doing so causes warnings in
> > gtype-desc.c, which does not preserve the const qualifier.
> >
> > Would it be better to add a cast around the assignment or to make
> > the GTY code handle const members?
>
> I'd prefer that you improved gengtype.
It's not gengtype, the problem really is that you cannot have const
GCed memory, for the same underlying reasons that you cannot free() a
const pointer.