Message ID | b7ef23bb-04d6-c07b-759b-c541058b2c93@netcologne.de |
---|---|
State | New |
Headers | show |
Series | [fortran] Fix PR 89174, segfault on allocate with MOLD | expand |
Hi Thomas, > Of course, there could also be a more profound way of fixing this > bug :-) I wish that it were the case. I am unable to decide whether the design choices made for an F95 compiler have cause the add-ons to be intrinsically complicated or whether or whether F2018, extensions and legacy support is the cause of the complexity - probably both. Either way, profundity is rarely to be found in bugfixes. > > Regression-tested on x86_64-pc-linux-gnu. OK for trunk and gcc-8? Yes, that's good for both branches. Thanks for the fix. Paul
On Sun, Feb 24, 2019 at 05:42:14PM +0000, Paul Richard Thomas wrote: > > > Of course, there could also be a more profound way of fixing this > > bug :-) > > I wish that it were the case. I am unable to decide whether the design > choices made for an F95 compiler have cause the add-ons to be > intrinsically complicated or whether or whether F2018, extensions and > legacy support is the cause of the complexity - probably both. Either > way, profundity is rarely to be found in bugfixes. > flang project was going to port PGI's frontend to use llvm as it middle/backend. A part of the port was to update PGI bits to include modern Fortran. The flang developers have decided to write an entirely new, from scratch, frontend. My conclusion is our 15+ year-old decisions and the addition of newer features (both modern Fortran and legacy) have complicated parts of the compiler to an almost unmanageable state. You can probably appreciate this better than most of us.
Index: trans-expr.c =================================================================== --- trans-expr.c (Revision 269161) +++ trans-expr.c (Arbeitskopie) @@ -352,7 +352,7 @@ gfc_vptr_size_get (tree vptr) of refs following. */ gfc_expr * -gfc_find_and_cut_at_last_class_ref (gfc_expr *e) +gfc_find_and_cut_at_last_class_ref (gfc_expr *e, bool is_mold) { gfc_expr *base_expr; gfc_ref *ref, *class_ref, *tail = NULL, *array_ref; @@ -394,7 +394,10 @@ gfc_expr * e->ref = NULL; } - base_expr = gfc_copy_expr (e); + if (is_mold) + base_expr = gfc_expr_to_initialize (e); + else + base_expr = gfc_copy_expr (e); /* Restore the original tail expression. */ if (class_ref) Index: trans-stmt.c =================================================================== --- trans-stmt.c (Revision 269161) +++ trans-stmt.c (Arbeitskopie) @@ -6641,7 +6641,7 @@ gfc_trans_allocate (gfc_code * code) /* Use class_init_assign to initialize expr. */ gfc_code *ini; ini = gfc_get_code (EXEC_INIT_ASSIGN); - ini->expr1 = gfc_find_and_cut_at_last_class_ref (expr); + ini->expr1 = gfc_find_and_cut_at_last_class_ref (expr, true); tmp = gfc_trans_class_init_assign (ini); gfc_free_statements (ini); gfc_add_expr_to_block (&block, tmp); Index: trans.h =================================================================== --- trans.h (Revision 269161) +++ trans.h (Arbeitskopie) @@ -412,7 +412,7 @@ tree gfc_class_data_get (tree); tree gfc_class_vptr_get (tree); tree gfc_class_len_get (tree); tree gfc_class_len_or_zero_get (tree); -gfc_expr * gfc_find_and_cut_at_last_class_ref (gfc_expr *); +gfc_expr * gfc_find_and_cut_at_last_class_ref (gfc_expr *, bool is_mold = false); /* Get an accessor to the class' vtab's * field, when a class handle is available. */ tree gfc_class_vtab_hash_get (tree);