Bug 91519 - [10 Regression] ICE error in 521.wrf_r
Summary: [10 Regression] ICE error in 521.wrf_r
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.0
: P4 normal
Target Milestone: 10.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 91524 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-08-22 04:28 UTC by Hongtao.liu
Modified: 2019-08-26 02:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-08-22 00:00:00


Attachments
samp.f90 (643 bytes, text/plain)
2019-08-22 04:28 UTC, Hongtao.liu
Details
module_comm_dm_3.mod (705.07 KB, audio/x-mod)
2019-08-22 04:30 UTC, Hongtao.liu
Details
Fortran source code (1.11 KB, application/gzip)
2019-08-22 07:13 UTC, Hongtao.liu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hongtao.liu 2019-08-22 04:28:21 UTC
Created attachment 46740 [details]
samp.f90

Compile option:
/usr/gcc10_20190821/bin/gfortran -O2 ./samp.f90 -S -mtune=generic

error message:

in gfc_format_decoder, at fortran/error.c:947
0x5e8059 gfc_format_decoder
	../../../gnu-toolchain/gcc/gcc/fortran/error.c:947
0x17cb961 pp_format(pretty_printer*, text_info*)
	../../../gnu-toolchain/gcc/gcc/pretty-print.c:1390
0x17b5f99 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
	../../../gnu-toolchain/gcc/gcc/diagnostic.c:1025
0x7fca90 gfc_error_opt
	../../../gnu-toolchain/gcc/gcc/fortran/error.c:1313
0x7fe15d gfc_error(char const*, ...)
	../../../gnu-toolchain/gcc/gcc/fortran/error.c:1342
0x898396 gfc_find_sym_tree(char const*, gfc_namespace*, int, gfc_symtree**)
	../../../gnu-toolchain/gcc/gcc/fortran/symbol.c:3239
0x8983cf gfc_find_symbol(char const*, gfc_namespace*, int, gfc_symbol**)
	../../../gnu-toolchain/gcc/gcc/fortran/symbol.c:3290
0x93d5c3 check_externals_expr
	../../../gnu-toolchain/gcc/gcc/fortran/frontend-passes.c:5397
0x940885 gfc_expr_walker(gfc_expr**, int (*)(gfc_expr**, int*, void*), void*)
	../../../gnu-toolchain/gcc/gcc/fortran/frontend-passes.c:4919
0x940ae9 gfc_expr_walker(gfc_expr**, int (*)(gfc_expr**, int*, void*), void*)
	../../../gnu-toolchain/gcc/gcc/fortran/frontend-passes.c:4926
0x94358a gfc_code_walker(gfc_code**, int (*)(gfc_code**, int*, void*), int (*)(gfc_expr**, int*, void*), void*)
	../../../gnu-toolchain/gcc/gcc/fortran/frontend-passes.c:5343
0x9435b7 gfc_code_walker(gfc_code**, int (*)(gfc_code**, int*, void*), int (*)(gfc_expr**, int*, void*), void*)
	../../../gnu-toolchain/gcc/gcc/fortran/frontend-passes.c:5345
0x944c61 gfc_check_externals(gfc_namespace*)
	../../../gnu-toolchain/gcc/gcc/fortran/frontend-passes.c:5453
0x944c86 gfc_check_externals(gfc_namespace*)
	../../../gnu-toolchain/gcc/gcc/fortran/frontend-passes.c:5458
0x85a714 gfc_parse_file()
	../../../gnu-toolchain/gcc/gcc/fortran/parse.c:6326
0x8a5c5f gfc_be_parse_file
	../../../gnu-toolchain/gcc/gcc/fortran/f95-lang.c:204
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Hongtao.liu 2019-08-22 04:30:18 UTC
Created attachment 46741 [details]
module_comm_dm_3.mod
Comment 2 Hongtao.liu 2019-08-22 04:52:26 UTC
It needs two *.mod* file which is too large for attachment. So I put them in github, refer to https://github.com/algebra84/521.wrf_r
Comment 3 Hongtao.liu 2019-08-22 04:55:55 UTC
It was ok two weeks ago, new regression from August 10th
Comment 4 kargls 2019-08-22 05:37:08 UTC
We need the Fortran source not the *.mod file.
Comment 5 Hongtao.liu 2019-08-22 06:01:32 UTC
(In reply to kargl from comment #4)
> We need the Fortran source not the *.mod file.

You can use samp.f90.
Comment 6 Hongtao.liu 2019-08-22 07:13:07 UTC
Created attachment 46744 [details]
Fortran source code

Command line to reproduce this issue.

gfortran -m64 -c -o module_comm_dm_3.fppized.o -O2 module_comm_dm_3.fppized.f90
gfortran -m64 -c -o module_comm_dm_4.fppized.o -O2 module_comm_dm_4.fppized.f90
gfortran -m64 -c -o module_comm_dm.fppized.o -O2 module_comm_dm.fppized.f90
Comment 7 kargls 2019-08-22 16:38:02 UTC
Thomas, this is fixed by

% svn diff gcc/fortran/frontend-passes.c 
Index: gcc/fortran/frontend-passes.c
===================================================================
--- gcc/fortran/frontend-passes.c       (revision 274676)
+++ gcc/fortran/frontend-passes.c       (working copy)
@@ -5391,7 +5391,7 @@ check_externals_expr (gfc_expr **ep, int *walk_subtree
     return 0;
 
   gsym = gfc_find_gsymbol (gfc_gsym_root, sym->name);
-  if (gsym == NULL)
+  if (gsym == NULL || gsym->ns == NULL)
     return 0;
 
   gfc_find_symbol (sym->name, gsym->ns, 0, &def_sym);


I don't know if this is correct.  The function check_externals_expr
is somewhat odd.  It is declared to return int, but all return
statements are 'return 0'.  This suggests to me that proper
declaration for this function is void.
Comment 8 Thomas Koenig 2019-08-22 18:13:10 UTC
Yes, the treatment of namespaces was dogdgy.

This is fixed in https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01438.html (not yet reviewed).

HJ, does this patch also fix the original test case?
Comment 9 Thomas Koenig 2019-08-22 18:48:45 UTC
(In reply to kargl from comment #7)

> The function check_externals_expr
> is somewhat odd.  It is declared to return int, but all return
> statements are 'return 0'.  This suggests to me that proper
> declaration for this function is void.

It's a callback function for the expression walker. A non-zero
return value would mean an immediate return. From frontend-passes.c:

#define WALK_SUBEXPR(NODE) \
  do							\
    {							\
      result = gfc_expr_walker (&(NODE), exprfn, data);	\
      if (result)					\
	return result;					\
    }							\
  while (0)
Comment 10 kargls 2019-08-22 19:00:04 UTC
*** Bug 91524 has been marked as a duplicate of this bug. ***
Comment 11 Thomas Koenig 2019-08-24 21:13:18 UTC
Author: tkoenig
Date: Sat Aug 24 21:12:45 2019
New Revision: 274902

URL: https://gcc.gnu.org/viewcvs?rev=274902&root=gcc&view=rev
Log:
2019-08-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/91390
	PR fortran/91519
	* frontend-passes.c (check_externals_procedure): New
	function. If a procedure is not in the translation unit, create
	an "interface" for it, including its formal arguments.
	(check_externals_code): Use check_externals_procedure for common
	code with check_externals_expr.
	(check_externals_expr): Vice versa.
	* gfortran.h (gfc_get_formal_from_actual-arglist): New prototype.
	(gfc_compare_actual_formal): New prototype.
	* interface.c (compare_actual_formal): Rename to
	(gfc_compare_actual_formal): New function, make global.
	(gfc_get_formal_from_actual_arglist): Make global, and move here from
	* trans-types.c (get_formal_from_actual_arglist): Remove here.
	(gfc_get_function_type): Use gfc_get_formal_from_actual_arglist.

2019-08-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/91390
	PR fortran/91519
	* gfortran.dg/bessel_3.f90: Add type mismatch errors.
	* gfortran.dg/coarray_7.f90: Rename subroutines to avoid
	additional errors.
	* gfortran.dg/g77/20010519-1.f: Add -std=legacy. Remove
	warnings for ASSIGN. Add warnings for type mismatch.
	* gfortran.dg/goacc/acc_on_device-1.f95: Add -std=legacy.
	Add catch-all warning.
	* gfortran.dg/internal_pack_9.f90: Rename subroutine to
	avoid type error.
	* gfortran.dg/internal_pack_9.f90: Add -std=legacy. Add
	warnings for type mismatch.
	* gfortran.dg/pr39937.f: Add -std=legacy and type warnings. Move
	here from
	* gfortran.fortran-torture/compile/pr39937.f: Move to
	gfortran.dg.


Added:
    trunk/gcc/testsuite/gfortran.dg/pr39937.f
Removed:
    trunk/gcc/testsuite/gfortran.fortran-torture/compile/pr39937.f
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/trans-types.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/bessel_3.f90
    trunk/gcc/testsuite/gfortran.dg/coarray_7.f90
    trunk/gcc/testsuite/gfortran.dg/g77/20010519-1.f
    trunk/gcc/testsuite/gfortran.dg/goacc/acc_on_device-1.f95
    trunk/gcc/testsuite/gfortran.dg/internal_pack_9.f90
    trunk/gcc/testsuite/gfortran.dg/pr24823.f
Comment 12 Thomas Koenig 2019-08-25 15:43:44 UTC
https://gcc.gnu.org/ml/gcc-testresults/2019-08/msg02751.html shows that
521.wrf_r is no longer failing.

Closing as fixed.
Comment 13 Hongtao.liu 2019-08-26 02:15:43 UTC
(In reply to Thomas Koenig from comment #12)
> https://gcc.gnu.org/ml/gcc-testresults/2019-08/msg02751.html shows that
> 521.wrf_r is no longer failing.
> 
> Closing as fixed.

Yes, thank you.
By the way, there's new fail in 527.cam4_r due to type mismatch.
Using -std=legacy can make it successfully built.