Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29279 Discussions

omitting brackets while calling type-bound procedure

holgerwolff
Beginner
1,676 Views

Hello

I made a simple error while familiarising myself with some Fortran 2003 features. However, the output of the Fortran compiler tells me that it encountered a catastrophic failure, and asked me to let you know. So here it is:

example code:

[fortran]module errormod
  implicit none

  type :: errortype
    real, private :: value
  contains
    procedure, public :: set => set_value
    procedure, public :: get => get_value
  end type

  private :: set_value, get_value

contains

  subroutine set_value( self, v )
    implicit none
    class(errortype)  :: self
    real, intent(in)  :: v
    self % value = v
  end subroutine set_value

  function get_value( self )
    implicit none
    class(errortype)  :: self
    real              :: get_value
    get_value = self % value
    return
  end function

end module errormod

program error
  use errormod
  implicit none
  
  type(errortype) :: e

  call e % set ( 1.0 )

  ! This fails to compile with a catastrophic error
  write (*, *) e % get

  ! This works
! write (*, *) e % get()

end program error
[/fortran]
When compiling, I get this error:
[bash]$ ifort -o error error.f90 
error.f90(41): catastrophic error: **Internal compiler error: internal abort** 
Please report this error along with the circumstances in which it occurred in a
Software Problem Report. Note: File and line given may not be explicit cause of this error. write (*, *) e % get ---------------^ compilation aborted for error.f90 (code 3) [/bash]
I don't know how to fill out a Software Problem Report, so I am posting this here.

And here some info about my system:

[bash]$ ifort --version
ifort (IFORT) 11.1 20091130
Copyright (C) 1985-2009 Intel Corporation.  All rights reserved.
$ uname -a
Linux xxxxxxx 2.6.32-24-generic #39-Ubuntu SMP Wed Jul 28 06:07:29 UTC 2010 i686 GNU/Linux[/bash]

Since I know where the error is in my code, and can correct it, I don't need an answer. So if this problem has been fixed, I'm happy for you to close and/or delete this thread.

0 Kudos
6 Replies
mecej4
Honored Contributor III
1,676 Views
This compiler error does not occur with version 11.1.072, which gives the syntax error:

"ibug1.f90(41): error #8319: An EXTERNAL procedure name must not appear in an input/output item list. [GET]"
0 Kudos
Ron_Green
Moderator
1,676 Views
We leave these threads in the forum in case others see the same issue.

Type bound procedures are one of the Fortran 2003 features we've been working on in 11.1 and the next version of the compiler.

ron
0 Kudos
Lester
Beginner
1,676 Views
Since putting parentheses after the get not only removes the error message from both versions of the compiler, but the resulting executable runs and give the correct answer, the 11.1.072 error message probably isn't right either.
0 Kudos
mecej4
Honored Contributor III
1,676 Views
Section 12.4, rule R1217 of the Fortran Standard (J3/04-007) shows the parentheses as mandatory for a function reference. The message could have said "...missing argument list and parentheses...".

Since a single syntax error may cause violations of more than one language syntax rule, it is difficult to pick in advance the best wording of the error message.
0 Kudos
Ron_Green
Moderator
1,676 Views
Let me ask our front-end team how easy/difficult it would be to improve the error message here. It would be nice to have a better message.

Simplified:

module errormod
implicit none

type :: errortype
real, private :: value
contains
procedure, public :: get => get_value
end type

private :: get_value

contains

function get_value( self )
implicit none
class(errortype) :: self
real :: get_value
get_value = self % value
return
end function

end module errormod

program error
use errormod
implicit none

type(errortype) :: e

! This is a user bug, forgot () after e%get()
write (*, *) e % get
! correct is: write(*,*) e % get()

end program error

0 Kudos
Ron_Green
Moderator
1,676 Views
We improved the error message in the Composer XE 2011 ( aka v12.0 ) compiler:
$ ifort reprou76793.F90
reprou76793.F90(31): error #8497: Illegal use of a procedure name in an expression, possibly a function call missing parenthesis. [GET]
write (*, *) e % get
-------------------^
$ ifort reprou76793.F90reprou76793.F90(31): error #8497: Illegal use of a procedure name in an expression, possibly a function call missing parenthesis. [GET]write (*, *) e % get-------------------^
0 Kudos
Reply