Hello Manuel, Manuel López-Ibáñez <lopeziba...@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