Bug 83246 - internal compiler error or loader problem might be related to a PARAMETER statement being in a BLOCK
Summary: internal compiler error or loader problem might be related to a PARAMETER sta...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 6.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-01 17:43 UTC by urbanjost
Modified: 2019-08-30 11:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-12-04 00:00:00


Attachments
create scratch file in BLOCK (1.13 KB, text/plain)
2017-12-01 17:43 UTC, urbanjost
Details
shorter case for just getting loader error (134 bytes, text/plain)
2017-12-01 19:22 UTC, urbanjost
Details
shorter case for internal compiler error (168 bytes, text/plain)
2017-12-01 19:23 UTC, urbanjost
Details

Note You need to log in before you can comment on or make changes to this bug.
Description urbanjost 2017-12-01 17:43:34 UTC
Created attachment 42769 [details]
create scratch file in BLOCK

Using GNU Fortran 6.4.0 on Cygwin I get various errors and/or this
  program runs making small changes to the test code. I only seem to
  have problems if I declare a PARAMETER in a BLOCK, but I thought 
  that was allowed? (Really have not used BLOCK much yet).
 
  If I have block MAKEDATA first I get loader error
 
  >/tmp/CCALL_CYGWIN64_GFORTRAN_8008/ccQ0aELt.o: In function `dusty_corner':
  >/tmp/CCALL_CYGWIN64_GFORTRAN_8008/yyy.8008.f90:28: undefined reference to `scratch.3494'
  >/tmp/CCALL_CYGWIN64_GFORTRAN_8008/yyy.8008.f90:28:(.text+0x79a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `scratch.3494'
 
  If I switch the order of MAKEDATA and MAKEDATAP blocks I get
  > MAKEDATA: block
  > 
  >internal compiler error: in gfc_process_block_locals, at fortran/trans-decl.c:6474
  >
  >/tmp/CCALL_CYGWIN64_GFORTRAN_131892/yyy.131892.f90:27:0: internal compiler error: Segmentation fault
  >mmap: No such device
  >Please submit a full bug report,
  >with preprocessed source if appropriate.
 
  If I comment out the first write statement ("BLOCK TESTS") the program works
    or
  If I comment out block MAKEDATAP the program works
Comment 1 kargl 2017-12-01 18:59:31 UTC
Reduce testcase.

program dusty_corner

   implicit none

   integer i

   write(*,*) 'Block tests' ! If this line is comment out program works.

   block
      character(len=*), parameter :: &
      &  str(*) = [character(len=20) :: '1', '2', '3', '4', '5', 'xxxx' ]
      open(10, status='scratch')
      write(10, '(a)')(trim(str(i)), i=1, size(str))
      close(10)
   end block

end program dusty_corner

It seems that gfortran is having problems with an implicit-shaped-array.
Comment 2 urbanjost 2017-12-01 19:22:13 UTC
Created attachment 42771 [details]
shorter case for just getting loader error
Comment 3 urbanjost 2017-12-01 19:23:04 UTC
Created attachment 42772 [details]
shorter case for internal compiler error
Comment 4 Dominique d'Humieres 2017-12-04 18:05:14 UTC
Confirmed from 4.8 up to trunk (8.0).
Comment 5 Jakub Jelinek 2019-02-01 22:54:37 UTC
Author: jakub
Date: Fri Feb  1 22:54:05 2019
New Revision: 268462

URL: https://gcc.gnu.org/viewcvs?rev=268462&root=gcc&view=rev
Log:
	PR fortran/83246
	PR fortran/89084
	* trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs
	if sym->ns->construct_entities rather than if
	sym->ns->parent->code->op == EXEC_BLOCK.

	* gfortran.dg/pr89084.f90: New test.
	* gfortran.dg/lto/pr89084_0.f90: New test.
	* gfortran.dg/pr83246.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90
    trunk/gcc/testsuite/gfortran.dg/pr83246.f90
    trunk/gcc/testsuite/gfortran.dg/pr89084.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2019-02-01 22:58:27 UTC
Should be fixed on the trunk now.
Comment 7 urbanjost 2019-02-04 03:50:47 UTC
Thanks!
Comment 8 Jakub Jelinek 2019-02-07 14:53:13 UTC
Author: jakub
Date: Thu Feb  7 14:52:41 2019
New Revision: 268642

URL: https://gcc.gnu.org/viewcvs?rev=268642&root=gcc&view=rev
Log:
	Backported from mainline
	2019-02-01  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/83246
	PR fortran/89084
	* trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs
	if sym->ns->construct_entities rather than if
	sym->ns->parent->code->op == EXEC_BLOCK.

	* gfortran.dg/pr89084.f90: New test.
	* gfortran.dg/lto/pr89084_0.f90: New test.
	* gfortran.dg/pr83246.f90: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr83246.f90
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr89084.f90
Modified:
    branches/gcc-8-branch/gcc/fortran/ChangeLog
    branches/gcc-8-branch/gcc/fortran/trans-decl.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 9 Jakub Jelinek 2019-08-30 11:36:42 UTC
Author: jakub
Date: Fri Aug 30 11:36:10 2019
New Revision: 275096

URL: https://gcc.gnu.org/viewcvs?rev=275096&root=gcc&view=rev
Log:
	Backported from mainline
	2019-02-01  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/83246
	PR fortran/89084
	* trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs
	if sym->ns->construct_entities rather than if
	sym->ns->parent->code->op == EXEC_BLOCK.

	* gfortran.dg/pr89084.f90: New test.
	* gfortran.dg/lto/pr89084_0.f90: New test.
	* gfortran.dg/pr83246.f90: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr83246.f90
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr89084.f90
Modified:
    branches/gcc-7-branch/gcc/fortran/ChangeLog
    branches/gcc-7-branch/gcc/fortran/trans-decl.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog