This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/66528] [6 Regression] unbalanced IF/ENDIF with -fmax-errors=1 causes invalid free
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Jun 2015 22:17:14 +0000
- Subject: [Bug fortran/66528] [6 Regression] unbalanced IF/ENDIF with -fmax-errors=1 causes invalid free
- Auto-submitted: auto-generated
- References: <bug-66528-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66528
--- Comment #6 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
Author: manu
Date: Wed Jun 24 22:16:42 2015
New Revision: 224926
URL: https://gcc.gnu.org/viewcvs?rev=224926&root=gcc&view=rev
Log:
The problem is that diagnostic_action_after_output tries to delete the active
pretty-printer which tries to delete its output_buffer, which is normally
dynamically allocated via placement-new, but the output_buffer used by the
error_buffer of Fortran is statically allocated. Being statically allocated
simplifies a lot pushing/poping several instances of error_buffer.
The solution is to reset the active output_buffer back to the default one
before calling diagnostic_action_after_output. This is a bit ugly, because this
function does use the output_buffer, however, at the point that Fortran calls
it, both are in an equivalent state, thus there is no visible difference.
gcc/testsuite/ChangeLog:
2015-06-24 Manuel LÃpez-IbÃÃez <manu@gcc.gnu.org>
PR fortran/66528
* gfortran.dg/maxerrors.f90: New test.
gcc/fortran/ChangeLog:
2015-06-24 Manuel LÃpez-IbÃÃez <manu@gcc.gnu.org>
PR fortran/66528
* error.c (gfc_warning_check): Restore the default output_buffer
before calling diagnostic_action_after_output.
(gfc_error_check): Likewise.
(gfc_diagnostics_init): Add comment.
Added:
trunk/gcc/testsuite/gfortran.dg/maxerrors.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/error.c
trunk/gcc/testsuite/ChangeLog