Hi Dominique,
(1) Why is this block reached when compiling with -ffrontend-optimize, but not
with -fno-frontend-optimize (Thomas)?
The problem here is that gfc_variable_attr is called (indirectly)
during optimize_assignment. In this case, this causes the ICE
because of the existing error condition.
Here is the backtrace:
#0 gfc_internal_error (gmsgid=gmsgid@entry=0x14e4170
"gfc_variable_attr(): Bad array reference") at
../../trunk/gcc/fortran/error.c:1288
#1 0x000000000069f15a in gfc_variable_attr (expr=<optimized out>,
ts=ts@entry=0x0) at ../../trunk/gcc/fortran/primary.c:2272
#2 0x000000000069f180 in gfc_expr_attr (e=e@entry=0x2162d20) at
../../trunk/gcc/fortran/primary.c:2351
#3 0x00000000006d50de in gfc_check_dependency (expr1=0x2162990,
expr2=0x2162d20, identical=<optimized out>) at
../../trunk/gcc/fortran/dependency.c:1292
#4 0x00000000006d5043 in gfc_check_dependency (expr1=0x2162990,
expr2=0x20da550, identical=true) at
../../trunk/gcc/fortran/dependency.c:1260
#5 0x0000000000770f8c in optimize_assignment (c=0x20da730) at
../../trunk/gcc/fortran/frontend-passes.c:1162
#6 optimize_code (c=<optimized out>, walk_subtrees=<optimized out>,
data=<optimized out>) at ../../trunk/gcc/fortran/frontend-passes.c:206
It might be worth not running the optimization when error conditions
exist. I'll think about this.
However, I have no objection to just removing the gfc_internal_error.
Regards
Thomas