[Bug fortran/84394] compiler error when using modules with derived types in block data subprograms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84394 --- Comment #2 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #1) > Breakpoint 1, check_conflict (attr=attr@entry=0x203caec38, > name=0x203c22430 "_deallocate", where=where@entry=0x203caec78) > at ../../gcc/gcc/fortran/symbol.c:485 > 485 gfc_error("%s attribute not allowed in BLOCK DATA program " > (gdb) p *where > $1 = {nextc = 0x0, lb = 0x0} > > So, gfortran is inserting a _deallocate (perhaps for a temporary array). > I suspect were can the conflict check for a name starting with an > underscore. I forgot to mention that attr->access = ACCESS_PRIVATE, which the actual root cause. I also suspect that the attr is re-using a previous attr struct without clear it first. In any case, the following works around the problem. Index: symbol.c === --- symbol.c(revision 257665) +++ symbol.c(working copy) @@ -479,11 +479,10 @@ check_conflict (symbol_attribute *attr, const char *na if (attr->intent != INTENT_UNKNOWN) a1 = intent; - if (a1 != NULL) + if (a1 != NULL && *name != '_') { - gfc_error - ("%s attribute not allowed in BLOCK DATA program unit at %L", -a1, where); + gfc_error("%s attribute not allowed in BLOCK DATA program " + "unit at %L", a1, where); return false; } }
[Bug fortran/84394] compiler error when using modules with derived types in block data subprograms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84394 kargl at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-02-15 CC||kargl at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from kargl at gcc dot gnu.org --- Further reduced testcase module mod1 implicit none type :: type1 integer :: i1 end type type1 end module module mod2 implicit none contains subroutine sub1 integer vals common /block1/ vals(5) if (any(vals /= [1, 2, 3, 4, 5])) stop 1 end subroutine end module block data blkdat use mod1 integer vals common /block1/ vals(5) data vals/1, 2, 3, 4, 5/ end block data blkdat program main use mod2, only: sub1 implicit none call sub1 end program Looking at 0x7f911f check_conflict ../../gcc/fortran/symbol.c:485 This is really odd. gdb shows Breakpoint 1, check_conflict (attr=attr@entry=0x203caec38, name=0x203c22430 "_deallocate", where=where@entry=0x203caec78) at ../../gcc/gcc/fortran/symbol.c:485 485 gfc_error("%s attribute not allowed in BLOCK DATA program " (gdb) p *where $1 = {nextc = 0x0, lb = 0x0} So, gfortran is inserting a _deallocate (perhaps for a temporary array). I suspect were can the conflict check for a name starting with an underscore.
[Bug fortran/84394] compiler error when using modules with derived types in block data subprograms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84394 kargl at gcc dot gnu.org changed: What|Removed |Added Priority|P3 |P4 Known to fail||7.3.1, 8.0