http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46067
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Summary|hang or spurious compiler |[F03] invalid procedure
|message using procedure |pointer assignment not
|pointer with pass |detected
--- Comment #2 from janus at gcc dot gnu.org 2010-10-18 20:08:52 UTC ---
(In reply to comment #1)
> > potential problem 2: if the error message is correct and if the type of the
> > passed-object dummy argument in the sample code is changed from a
> > declaration
> > of "type" to "class", the module compiles but hangs when the passed-object
> > dummy argument is referenced.
>
> After changing the PASS arg from TYPE to CLASS, the module compiles fine for
> me
> without any hanging (on x86_64-unknown-linux-gnu at r165600).
Ok, one has to be a little careful at this point: When changing both TYPE
declarations into CLASS (inside 'fun_interface' and 'fun1'), the program
compiles ok and apparently gives the correct output (assuming that the
undefined variable 'pi' is zero, contrary to its suggestive name):
fun1(pi) id = 1
1.0000000
However, when changing only the TYPE declaration in 'fun_interface', but not
the one in 'fun1', the program compiles but gives bogus results:
fun1(pi) id = 6295264
1.0000000
This is due to the fact that the resulting program is invalid, which gfortran
currently fails to detect.
In summary: The only bug that gfortran exhibits in the context of this PR is
the fact that it does not reject the invalid procedure pointer assignment in
the following program:
implicit none
type test_type
integer :: id
procedure(fun_interface), pointer, pass :: fun_ptr
end type test_type
abstract interface
function fun_interface(t,x) result(res)
import :: test_type
real, intent(in) :: x
class(test_type) :: t
real :: res
end function fun_interface
end interface
type(test_type),dimension(1) :: funs
funs(1)%id = 1
funs(1)%fun_ptr => fun1 !!! invalid !!!
print *, " fun1(pi) ",funs(1)%fun_ptr(0.)
contains
function fun1 (t,x) result (res)
real, intent(in) :: x
type(test_type) :: t
real :: res
print *," id = ", t%id
res=cos(x)
end function fun1
end