[PATCH][C++] Fix dump-file corruption
Richard Guenther
rguenther@suse.de
Mon Oct 10 14:21:00 GMT 2005
On Mon, 10 Oct 2005, Daniel Berlin wrote:
> On Sun, 2005-10-09 at 06:29 -0700, Mark Mitchell wrote:
> > Richard Guenther wrote:
> >
> > > Fixed by moving (swapping) a cached decls name to the position it would
> > > have had if it had been freshly allocated. This ensures that we can
> > > reliably print strings with at least RING_SIZE decl names in them.
> >
> > But, not with more names than that. It's a bug to hold on to the memory
> > returned by cxx_printable_name; you have to either print or copy the
> > returned value immediately. So, I don't think the bug is in
> > cxx_printable_name; it sounds like the bug is in whatever part of the
> > compiler is trying to hold on to those values.
>
> I have to agree.
> I believe the assumption all our name returning functions make is that
> the memory they return is *not* yours to free or keep.
> If you want your own copy, you have to make it.
>
> At least, this is the assumption i've always worked under when dealing
> with names (see tree-ssa-structalias.c :P)
Of course - but the ringbuffer (with a from the gcc sources statically
predictable minimum size) for stuff like using printf with format strings
is a valid and good approach. And with my fix we get what this beast
was probably designed for -- providing state for this statically
determined maximum number of strings.
Richard.
More information about the Gcc-patches
mailing list