Bug 71838 - ICE with OpenCoarrays on submodule
Summary: ICE with OpenCoarrays on submodule
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 6.1.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-11 09:30 UTC by Anton Shterenlikht
Modified: 2017-04-01 11:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-11 00:00:00


Attachments
Fix for the PR (1.43 KB, patch)
2017-02-26 14:46 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Shterenlikht 2016-07-11 09:30:52 UTC
‘
in pp_string, at pretty-print.c:928
0x1346eab pp_string(pretty_printer*, char const*)
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/pretty-print.c:928
0x134789f pp_format(pretty_printer*, text_info*)
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/pretty-print.c:570
0x1342da8 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/diagnostic.c:825
0x63bbb8 gfc_error_now(char const*, ...)
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/error.c:1179
0x6ba236 check_conflict
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/symbol.c:469
0x6be0d6 gfc_copy_attr(symbol_attribute*, symbol_attribute*, locus*)
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/symbol.c:1939
0x6bf1d5 gfc_copy_dummy_sym(gfc_symbol**, gfc_symbol*, int)
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/symbol.c:2011
0x632ecb gfc_match_submod_proc()
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/decl.c:7765
0x685d2d decode_statement
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/parse.c:383
0x687834 next_free
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/parse.c:1076
0x687834 next_statement
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/parse.c:1310
0x68b42c parse_contained
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/parse.c:5039
0x68c269 parse_module
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/parse.c:5432
0x68cc39 gfc_parse_file()
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/parse.c:5738
0x6ce875 gfc_be_parse_file
        /panfs/panasas01/mech/mexas/gcc-6-20160410-obj/../gcc-6-20160410/gcc/fortran/f95-lang.c:201
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [m3clvg_sm3.o] Error 1

The source file is a submodue:

 https://sourceforge.net/p/cgpack/code/HEAD/tree/head/m3clvg_sm3.f90

The module is:

 https://sourceforge.net/p/cgpack/code/HEAD/tree/head/cgca_m3clvg.f90

The Makefile is:

https://sourceforge.net/p/cgpack/code/HEAD/tree/head/Makefile-bc3-oca

$ caf --version

OpenCoarrays Coarray Fortran Compiler Wrapper (caf version 1.4.0)
Copyright (C) 2015-2016 Sourcery, Inc.
Comment 1 Anton Shterenlikht 2016-07-11 11:26:21 UTC
with OpenCoarrays-1.6.0 I just get:

caf -c -Wall -g -fbacktrace -fcheck-array-temporaries  m3clvg_sm3.f90
'
(null):0: confused by earlier errors, bailing out
make: *** [m3clvg_sm3.o] Error 1


But there are no "earlier errors" reported.
Comment 2 Anton Shterenlikht 2016-07-11 11:28:16 UTC
forgot to add that this is now with gcc-6.1:

$ caf --version

OpenCoarrays Coarray Fortran Compiler Wrapper (caf version 1.6.0)
Copyright (C) 2015-2016 Sourcery, Inc.

$ mpif90 --version
GNU Fortran (GCC) 6.1.0
Comment 3 Dominique d'Humieres 2016-07-11 12:03:04 UTC
> The module is:
> https://sourceforge.net/p/cgpack/code/HEAD/tree/head/cgca_m3clvg.f90

This module uses several other modules.

> (null):0: confused by earlier errors, bailing out

This occurs when using a compiler configures with --enable-checking=release (default for releases).
Comment 4 Anton Shterenlikht 2016-07-11 13:43:53 UTC
Yes, it's a library:
 https://sourceforge.net/p/cgpack/code/HEAD/tree/head/

I'll try to reduce the problem case to something smaller.
Comment 5 Anton Shterenlikht 2016-07-11 14:59:44 UTC
I reduced the case to 8 Fortran files:
http://eis.bris.ac.uk/~mexas/0.txz

Untar the file
cd zproblem
make

caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  cgca_m1co.f90
caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  cgca_m2gb.f90
caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  cgca_m2glm.f90
caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  cgca_m2hx.f90
caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  cgca_m2rot.f90
caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  cgca_m2rnd.f90
caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  cgca_m3clvg.f90
caf      -c -Wall -g -fbacktrace -fcheck-array-temporaries  m3clvg_sm3.f90
'
(null):0: confused by earlier errors, bailing out
make: *** [m3clvg_sm3.o] Error 1
Comment 6 Dominique d'Humieres 2016-07-11 15:30:24 UTC
I get the ICE with the following trivial submodule

submodule ( cgca_m3clvg ) m3clvg_sm3

implicit none

contains

module procedure cgca_clvgp

end procedure cgca_clvgp

end submodule m3clvg_sm3

!-(
Comment 7 Paul Thomas 2017-02-20 11:06:45 UTC
(In reply to Dominique d'Humieres from comment #6)
> I get the ICE with the following trivial submodule
> 
> submodule ( cgca_m3clvg ) m3clvg_sm3
> 
> implicit none
> 
> contains
> 
> module procedure cgca_clvgp
> 
> end procedure cgca_clvgp
> 
> end submodule m3clvg_sm3
> 
> !-(

Dominique,

This now produces:

[pault@pc30 pr71838]$ ~/irun/bin/gfortran -static-libgfortran p*.f90
f951: Fatal Error: Module file ‘cgca_m3clvg.smod’ has not been generated, either because the module does not contain a MODULE PROCEDURE or there is an error in the module.
compilation terminated.

Is the original bug similarly fixed?

Ciao

Paul
Comment 8 Dominique d'Humieres 2017-02-21 14:01:12 UTC
> This now produces:
>
> [pault@pc30 pr71838]$ ~/irun/bin/gfortran -static-libgfortran p*.f90
> f951: Fatal Error: Module file ‘cgca_m3clvg.smod’ has not been generated,
> either because the module does not contain a MODULE PROCEDURE or there is
> an error in the module.
> compilation terminated.

The ICE reported for the reduced test in comment 6 was found after the steps in comment 5 and in the same directory.

Note that the reduced test

module cgca_m3clvg
  interface
    module subroutine cgca_clvgp()
    end subroutine cgca_clvgp
  end interface
end module cgca_m3clvg

submodule ( cgca_m3clvg ) m3clvg_sm3

implicit none

contains

module procedure cgca_clvgp

end procedure cgca_clvgp

end submodule m3clvg_sm3

compiles.

> Is the original bug similarly fixed?

No!
Comment 9 Dominique d'Humieres 2017-02-21 14:23:55 UTC
Reduced test

module cgca_m3clvg
abstract interface
 subroutine cgca_clvgs_abstract( farr, marr, n, cstate, debug,         &
                                 newstate )
    integer, parameter :: iarr = 4, idef = 4, rdef = 4, ldef = 4
  integer, parameter :: l=-1, centre=l+1, u=centre+1
  integer( kind=iarr ), intent(in) :: farr(l:u,l:u,l:u),               &
    marr(l:u,l:u,l:u), cstate
  real( kind=rdef ), intent(in) :: n(3)
  logical( kind=ldef ), intent(in) :: debug
  integer( kind=iarr ), intent(out) :: newstate
 end subroutine cgca_clvgs_abstract

end interface

  interface
  module subroutine cgca_clvgp( coarray, rt, t, scrit, sub, gcus,      &
                                periodicbc, iter, heartbeat, debug )
    integer, parameter :: iarr = 4, idef = 4, rdef = 4, ldef = 4
    integer( kind=iarr ), allocatable, intent(inout) ::                &
      coarray(:,:,:,:)[:,:,:]
    real( kind=rdef ), allocatable, intent(inout) :: rt(:,:,:)[:,:,:]
    real( kind=rdef ), intent(in) :: t(3,3), scrit(3)
    procedure( cgca_clvgs_abstract ) :: sub
    logical( kind=ldef ), intent(in) :: periodicbc
    integer( kind=idef ), intent(in) :: iter, heartbeat
    logical( kind=ldef ), intent(in) :: debug
  end subroutine cgca_clvgp
end interface

end module cgca_m3clvg

submodule ( cgca_m3clvg ) m3clvg_sm3

implicit none

contains

module procedure cgca_clvgp

abstract interface
 subroutine cgca_clvgs_abstract( farr, marr, n, cstate, debug,         &
                                 newstate )
    integer, parameter :: iarr = 4, idef = 4, rdef = 4, ldef = 4
  integer, parameter :: l=-1, centre=l+1, u=centre+1
  integer( kind=iarr ), intent(in) :: farr(l:u,l:u,l:u),               &
    marr(l:u,l:u,l:u), cstate
  real( kind=rdef ), intent(in) :: n(3)
  logical( kind=ldef ), intent(in) :: debug
  integer( kind=iarr ), intent(out) :: newstate
 end subroutine cgca_clvgs_abstract

end interface

  interface
  module subroutine cgca_clvgp( coarray, rt, t, scrit, sub, gcus,      &
                                periodicbc, iter, heartbeat, debug )
    integer, parameter :: iarr = 4, idef = 4, rdef = 4, ldef = 4
    integer( kind=iarr ), allocatable, intent(inout) ::                &
      coarray(:,:,:,:)[:,:,:]
    real( kind=rdef ), allocatable, intent(inout) :: rt(:,:,:)[:,:,:]
    real( kind=rdef ), intent(in) :: t(3,3), scrit(3)
    procedure( cgca_clvgs_abstract ) :: sub
    logical( kind=ldef ), intent(in) :: periodicbc
    integer( kind=idef ), intent(in) :: iter, heartbeat
    logical( kind=ldef ), intent(in) :: debug
  end subroutine cgca_clvgp
end interface

end module cgca_m3clvg

submodule ( cgca_m3clvg ) m3clvg_sm3

implicit none

contains

module procedure cgca_clvgp

end procedure cgca_clvgp

end submodule m3clvg_sm3
Comment 10 Dominique d'Humieres 2017-02-21 18:16:02 UTC
Further reduced test

module cgca_m3clvg
abstract interface
 subroutine cgca_clvgs_abstract()
 end subroutine cgca_clvgs_abstract

end interface

  interface
  module subroutine cgca_clvgp(sub)
    procedure( cgca_clvgs_abstract ) :: sub
  end subroutine cgca_clvgp
end interface

end module cgca_m3clvg

submodule ( cgca_m3clvg ) m3clvg_sm3

implicit none

contains

module procedure cgca_clvgp

end procedure cgca_clvgp

end submodule m3clvg_sm3

end
Comment 11 Dominique d'Humieres 2017-02-21 18:32:29 UTC
Even further reduced test

module cgca_m3clvg
  interface
    subroutine cgca_clvgs_abstract()
    end subroutine cgca_clvgs_abstract
    module subroutine cgca_clvgp(sub)
      procedure( cgca_clvgs_abstract ) :: sub
    end subroutine cgca_clvgp
  end interface
end module cgca_m3clvg

submodule ( cgca_m3clvg ) m3clvg_sm3
implicit none
contains
  module procedure cgca_clvgp
  end procedure cgca_clvgp
end submodule m3clvg_sm3
Comment 12 Paul Thomas 2017-02-26 14:46:37 UTC
Created attachment 40834 [details]
Fix for the PR

The attached is a patch for the PR which is regtesting right now and will be submitted if all is well.

Anton, if you are in a position to do so, I would be grateful if you would check that your code now compiles and runs correctly... well, that this bug is no longer a problem, anyway :-)

Paul
Comment 13 Anton Shterenlikht 2017-02-27 09:58:04 UTC
The latest I have is:

gcc6-devel-6.3.1.s20161229     lang/gcc6-devel
gcc7-devel-7.0.0.s20170101     lang/gcc7-devel

ATM I've no time to build gcc myself.
I'll wait for gerald@ to update these ports and will try again.

Thanks!

Anton
Comment 14 paul.richard.thomas@gmail.com 2017-02-27 10:23:48 UTC
Hi Anton,

Did you take on board that it is the procedure dummy argument that
causes the problem?

A viable workaround is to:
s/procedure( cgca_clvgs_abstract ) :: sub/external :: sub/

Cheers

Paul


On 27 February 2017 at 09:58, mexas at bristol dot ac.uk
<gcc-bugzilla@gcc.gnu.org> wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71838
>
> --- Comment #13 from Anton Shterenlikht <mexas at bristol dot ac.uk> ---
>
> The latest I have is:
>
> gcc6-devel-6.3.1.s20161229     lang/gcc6-devel
> gcc7-devel-7.0.0.s20170101     lang/gcc7-devel
>
> ATM I've no time to build gcc myself.
> I'll wait for gerald@ to update these ports and will try again.
>
> Thanks!
>
> Anton
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.
Comment 15 Anton Shterenlikht 2017-03-14 15:52:56 UTC
Yes, the problem seems to have been solved.
My code compiles fine now.

Thanks

Anton
Comment 16 Paul Thomas 2017-03-18 11:54:25 UTC
Author: pault
Date: Sat Mar 18 11:53:53 2017
New Revision: 246255

URL: https://gcc.gnu.org/viewcvs?rev=246255&root=gcc&view=rev
Log:
2017-03-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/71838
	* symbol.c (check_conflict): A dummy procedure in a submodule,
	module procedure is not an error.
	(gfc_add_flavor): Ditto.

2017-03-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/71838
	* gfortran.dg/submodule_26.f08 : New test.
	* gfortran.dg/submodule_27.f08 : New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/submodule_26.f08
    trunk/gcc/testsuite/gfortran.dg/submodule_27.f08
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
Comment 17 Paul Thomas 2017-04-01 11:35:47 UTC
Author: pault
Date: Sat Apr  1 11:35:14 2017
New Revision: 246632

URL: https://gcc.gnu.org/viewcvs?rev=246632&root=gcc&view=rev
Log:
2017-04-01  Paul Thomas  <pault@gcc.gnu.org>

	Backport from trunk
	PR fortran/71838
	* symbol.c (check_conflict): A dummy procedure in a submodule,
	module procedure is not an error.
	(gfc_add_flavor): Ditto.

2017-04-01  Paul Thomas  <pault@gcc.gnu.org>

	Backport from trunk
	PR fortran/71838
	* gfortran.dg/submodule_26.f08 : New test.
	* gfortran.dg/submodule_27.f08 : New test.


Added:
    branches/gcc-6-branch/gcc/testsuite/gfortran.dg/submodule_26.f08
    branches/gcc-6-branch/gcc/testsuite/gfortran.dg/submodule_27.f08
Modified:
    branches/gcc-6-branch/gcc/fortran/ChangeLog
    branches/gcc-6-branch/gcc/fortran/symbol.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 18 Paul Thomas 2017-04-01 11:37:23 UTC
Fixed on trunk and 6-branch.

Thanks for the report

Paul