This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH fortran/diagnostics] Move gfc_error (buffered) to common diagnostics
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- Cc: Tobias Burnus <burnus at net-b dot de>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, "fortran\ at gcc dot gnu dot org List" <fortran at gcc dot gnu dot org>
- Date: Wed, 10 Dec 2014 13:54:18 +0100
- Subject: Re: [PATCH fortran/diagnostics] Move gfc_error (buffered) to common diagnostics
- Authentication-results: sourceware.org; auth=none
- References: <CAESRpQAAk9nQub8W7Wv+8gXv5d9ovSxFgQh8QLYkUX7xswW=rg at mail dot gmail dot com> <CAESRpQCo3ycino1GJGympS4ZALHwHQ1+p-vbngBEaZZf8atBLA at mail dot gmail dot com>
Hello Manuel,
Manuel LÃpez-IbÃÃez <lopezibanez@gmail.com> writes:
> New version of the patch. Tobias noticed several problems with the
> previous version:
>
> * Due to the use of placement-new for the buffered output_buffers
> pp_warning_buffer and pp_error_buffer, the pretty-printer destructor
> may end up trying to free something that it can't. Fixed here by not
> using placement new.
So:
[...]
> /* Report the number of warnings and errors that occurred to the caller. */
>
> @@ -1525,11 +1625,14 @@ gfc_diagnostics_init (void)
> {
> diagnostic_starter (global_dc) = gfc_diagnostic_starter;
> diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
> diagnostic_format_decoder (global_dc) = gfc_format_decoder;
> global_dc->caret_char = '^';
> - new (&pp_warning_buffer) output_buffer ();
> + pp_warning_buffer = new output_buffer ();
When I look at the code of the destructor the pretty_printer type
(pretty_printer::~pretty_printer) in gcc/pretty-print.c, I see that the
memory for the output buffer is de-allocated using XDELETE. So I think
the memory for the output buffer should be allocated using XNEW and the
output_buffer type should instantiated using a placement new operator
that uses that XNEWed allocated memory.
Ultimately, I should sit down and make sure the memory management of the
pretty_printer type does away with this surprising placement new
business for good.
> + pp_warning_buffer->flush_p = false;
> + pp_error_buffer = new output_buffer ();
> + pp_error_buffer->flush_p = false;
> }
Cheers,
--
Dodji