This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix memory leak in C++ pretty printer
- From: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- To: Patrick Palka <"patrick at parcs dot ath dot cx">, gcc-patches at gcc dot gnu dot org
- Cc: jason at redhat dot com
- Date: Mon, 11 May 2015 15:03:55 +0200
- Subject: Re: [PATCH] Fix memory leak in C++ pretty printer
- Authentication-results: sourceware.org; auth=none
- References: <1431308052-31361-1-git-send-email-patrick at parcs dot ath dot cx>
On 11/05/15 03:34, Patrick Palka wrote:
In gcc/cp/error.c we initialize the C++ pretty printer object twice:
first during statics initialization and later in a placement-new in
init_error(). This double-initialization causes a memory leak of about
7kb according to valgrind. I don't see a reason to initialize the
object a second time so I elected to remove init_error().
I seem to remember there is some issue with the constructors when using static
initialization that requires the placement-new. We also do the placement-new
dance in the other FEs and the reason should be the same.
My preference would be to replace the static with a pointer and placement-new
with proper new and delete, but see:
If you change it here, please change it everywhere else where we use
placement-new, such that all FEs are consistent on this.