[Bug fortran/88043] Runtime Error when calling deferred member function

2018-11-15 Thread zjibben at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88043

--- Comment #2 from Zach Jibben  ---
I'll also add that removing the non_overridable attribute from bar%f (B%sub in
Neil's example) causes the error to disappear, and seems like the most
reasonable workaround for the time being.

[Bug fortran/88043] New: Runtime Error when calling deferred member function

2018-11-15 Thread zjibben at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88043

Bug ID: 88043
   Summary: Runtime Error when calling deferred member function
   Product: gcc
   Version: 8.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zjibben at gmail dot com
CC: neil.n.carlson at gmail dot com
  Target Milestone: ---

A call to a deferred member procedure ends up calling a different procedure
instead. It looks like the virtual function table is incorrect when passing
between two source files. I have a small example (~100 lines) in two source
files here:

https://github.com/nncarlson/fortran-compiler-tests/blob/master/gfortran-bugs/gfortran-20181114-main.f90

https://github.com/nncarlson/fortran-compiler-tests/blob/master/gfortran-bugs/gfortran-20181114.f90

In this case, the routine never_call1 is called recursively, despite there
being no real calls to that function. With -fcheck=all this is caught,
otherwise it will consume your entire stack. Compiled using gfortran 8.2.1
20180831:

$ gfortran -g -fcheck=all gfortran-20181114.f90 gfortran-20181114-main.f90
$ ./a.out
At line 39 of file gfortran-20181114.f90
Fortran runtime error: Recursive call to nonrecursive procedure 'never_call1'

Error termination. Backtrace:
#0  0x55b1599cd19d in __foo_class_MOD_never_call1
at .../gfortran-20181114.f90:39
#1  0x55b1599cd1bc in __foo_class_MOD_never_call1
at .../gfortran-20181114.f90:42
#2  0x55b1599cd220 in __foo_class_MOD_call_me
at .../gfortran-20181114.f90:34
#3  0x55b1599cd449 in test
at .../gfortran-20181114-main.f90:42
#4  0x55b1599cd49f in main
at .../gfortran-20181114-main.f90:32