Bug 41389 - problem compiling file
Summary: problem compiling file
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-17 17:05 UTC by Norman S. Clerman
Modified: 2009-09-21 07:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Norman S. Clerman 2009-09-17 17:05:27 UTC
to the gfortran development team,

  Here is a file that I am trying to compile:

module exceptions

  ! Purpose: module for the program-wide exceptions

  ! Author: N. S. Clerman

  ! Notes:
  ! =====

  ! N. S. Clerman, 5 Sept. 2009: there is a problem here. Calls are made to Set_flag, which is not pure. No procedure that
  ! invokes it can be pure. I need to check the Fortran exception handling to see what happens. (I would think that not
  ! the case.) The exceptions themselves -- exception_array -- are private, so I think I could potentially be calling
  ! this simultaneously from more than one thread, but how do I handle the case where one thread is setting the flag to
  ! SIGNALLING and another to QUIET?

  implicit none
  private

  public :: Get_flag, Set_flag

!  public :: UNKNOWN_INDEX, BAD_YEAR_INDEX, BAD_MONTH_INDEX, BAD_DAY_INDEX, BAD_DATE_INDEX
!  public :: READ_ERROR_INDEX, FILE_OPEN_ERROR_INDEX, BAD_PRICE_INDEX, BAD_NO_OF_SHARES_INDEX
!  public :: BAD_TRANSACTION_INDEX, UNOPENED_PORTFOLIO_INDEX, EMPTY_PORTFOLIO_INDEX
!  public :: PORTFOLIO_OPENED_INDEX, BAD_PORTFOLIO_NAME_INDEX
!  public :: LAST_INDEX, ALLOCATION_ERROR_INDEX

  logical, public, parameter :: QUIET = .false., SIGNALLING = .true.

  type, public :: exception_t
    logical :: flag = QUIET
  end type exception_t

  type, private :: exception_flag_t
    integer :: flag_index
  end type exception_flag_t

  enum, bind(c)
    enumerator :: UNKNOWN_INDEX, BAD_YEAR_INDEX, BAD_MONTH_INDEX, BAD_DAY_INDEX, BAD_DATE_INDEX , &
         READ_ERROR_INDEX, FILE_OPEN_ERROR_INDEX, BAD_PRICE_INDEX, BAD_NO_OF_SHARES_INDEX, &
         BAD_TRANSACTION_INDEX, UNOPENED_PORTFOLIO_INDEX, EMPTY_PORTFOLIO_INDEX, &
         PORTFOLIO_OPENED_INDEX, BAD_PORTFOLIO_NAME_INDEX, ALLOCATION_ERROR_INDEX, EMPTY_INVESTOR_INDEX, &

         LAST_INDEX
  end enum

  ! UNKNOWN_FLAG -
  ! BAD_YEAR_FLAG - year is out of exceptable range
  ! BAD_MONTH_FLAG - month is out of range
  ! BAD_DAY_FLAG - day is out of range
  ! BAD_DATE_FLAG - date is out of range
  ! READ_ERROR_FLAG - problem reading with read statement
  ! FILE_OPEN_ERROR_FLAG - problem opening a file with the open statement.
  ! BAD_PRICE_FLAG - negative price
  ! BAD_NO_OF_SHARES_FLAG -
  ! BAD_TRANSACTION_FLAG -
  !

  type (exception_flag_t), public, parameter :: &
       UNKNOWN_FLAG    = exception_flag_t (UNKNOWN_INDEX),   &
       BAD_YEAR_FLAG   = exception_flag_t (BAD_YEAR_INDEX),  &
       BAD_MONTH_FLAG  = exception_flag_t (BAD_MONTH_INDEX), &
       BAD_DAY_FLAG    = exception_flag_t (BAD_DAY_INDEX),   &
       BAD_DATE_FLAG   = exception_flag_t (BAD_DATE_INDEX),  &
       READ_ERROR_FLAG = exception_flag_t (READ_ERROR_INDEX), &
       FILE_OPEN_ERROR_FLAG = exception_flag_t (FILE_OPEN_ERROR_INDEX), &
       BAD_PRICE_FLAG       = exception_flag_t (BAD_PRICE_INDEX), &
       BAD_NO_OF_SHARES_FLAG   = exception_flag_t (BAD_NO_OF_SHARES_INDEX), &
       BAD_TRANSACTION_FLAG    = exception_flag_t (BAD_TRANSACTION_INDEX), &
       EMPTY_PORTFOLIO_FLAG    = exception_flag_t (EMPTY_PORTFOLIO_INDEX), &
       PORTFOLIO_OPENED_FLAG   = exception_flag_t (PORTFOLIO_OPENED_INDEX), &
       BAD_PORTFOLIO_NAME_FLAG = exception_flag_t (BAD_PORTFOLIO_NAME_INDEX), &
       ALLOCATION_ERROR_FLAG   = exception_flag_t (ALLOCATION_ERROR_INDEX), &
       EMPTY_INVESTOR_FLAG     = exception_flag_t (EMPTY_INVESTOR_INDEX)

  type (exception_t), save :: exception_array(0: LAST_INDEX - 1)

contains

  elemental function Get_flag (flag_) result (return_value)

    type (exception_flag_t), intent (in) :: flag_
    logical :: return_value

    if (lbound (exception_array, dim = 1) <= flag_% flag_index .and. flag_% flag_index <= ubound (exception_array, dim = 1) ) &
         return_value = exception_array (flag_% flag_index) % flag

  end function Get_flag

  subroutine Set_flag (flag_, passed_value_)

    type (exception_flag_t), intent (in) :: flag_
    logical, intent (in) :: passed_value_

    if (lbound (exception_array, dim = 1) <= flag_% flag_index .and. flag_% flag_index <= ubound (exception_array, dim = 1) ) &
         exception_array(flag_% flag_index) = exception_t (passed_value_)

  end subroutine Set_flag

end module exceptions

here is the output of the compilaton:

norm@oxford:~/allocator> cat exceptions.gfortran.xyz
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /home/tob/projects/gcc-trunk-checkout/configure --with-gmp-lib=/home/tob/projects/gcc-build/lib-aux --with-mpfr-lib=/home/tob/projects/gcc-build/lib-aux --with-mpc-lib=/home/tob/projects/gcc-build/lib-aux --enable-languages=c,fortran,c++ --prefix=/projects/tob/gcc-trunk
Thread model: posix
gcc version 4.5.0 20090917 (experimental) [trunk revision 151786] (GCC)
COLLECT_GCC_OPTIONS='-c' '-g' '-Wall' '-std=f2003' '-O0' '-v' '-mtune=generic'
 /opt/gfortran/gcc-trunk/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/f951 exceptionsM.f90 -quiet -dumpbase exceptionsM.f90 -mtune=generic -auxbase exceptionsM -g -O0 -Wall -std=f2003 -version -fintrinsic-modules-path /opt/gfortran/gcc-trunk/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/finclude -o /tmp/ccvPWckV.s
GNU Fortran (GCC) version 4.5.0 20090917 (experimental) [trunk revision 151786] (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.5.0 20090917 (experimental) [trunk revision 151786], GMP version 4.3.1, MPFR version 2.4.1-p5, MPC version 0.6
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU Fortran (GCC) version 4.5.0 20090917 (experimental) [trunk revision 151786] (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.5.0 20090917 (experimental) [trunk revision 151786], GMP version 4.3.1, MPFR version 2.4.1-p5, MPC version 0.6
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
COLLECT_GCC_OPTIONS='-c' '-g' '-Wall' '-std=f2003' '-O0' '-v' '-mtune=generic'
 as -V -Qy -o exceptionsM.o /tmp/ccvPWckV.s
GNU assembler version 2.19 (x86_64-suse-linux) using BFD version (GNU Binutils; openSUSE 11.1) 2.19
/tmp/ccvPWckV.s: Assembler messages:
/tmp/ccvPWckV.s:133: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:133: Error: junk at end of line, first unrecognized character is `1'
/tmp/ccvPWckV.s:136: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:136: Error: junk at end of line, first unrecognized character is `1'
/tmp/ccvPWckV.s:140: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:140: Error: junk at end of line, first unrecognized character is `2'
/tmp/ccvPWckV.s:143: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:143: Error: junk at end of line, first unrecognized character is `2'
/tmp/ccvPWckV.s:145: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:145: Error: junk at end of line, first unrecognized character is `2'
/tmp/ccvPWckV.s:148: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:148: Error: junk at end of line, first unrecognized character is `2'
/tmp/ccvPWckV.s:181: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:181: Error: junk at end of line, first unrecognized character is `1'
/tmp/ccvPWckV.s:184: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:184: Error: junk at end of line, first unrecognized character is `1'
/tmp/ccvPWckV.s:187: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:187: Error: junk at end of line, first unrecognized character is `2'
/tmp/ccvPWckV.s:190: Error: unknown .loc sub-directive `discriminator'
/tmp/ccvPWckV.s:190: Error: junk at end of line, first unrecognized character is `2'

  I'm afraid I cannot interpret this problem. Perhaps I am using the incorrect flags, but they are the same that I am using to compile files that are far longer and more complicated. (Both version 5.2 of the nag compiler and version 11.1 of the Intel compiler are able to successfully compile this file.)

Yours truly,

Norm

Norm Clerman
Comment 1 Dominique d'Humieres 2009-09-17 20:08:45 UTC
4.2.4 gives

pr41389.f90:19.20:

  public :: Get_flag, Set_flag
                   1
Error: 'flag_' is of a PRIVATE type and cannot be a dummy argument of 'get_flag', which is PUBLIC at (1)

probably a bug fixed since then, but the code compiles for me (i686-apple-darwin9) with 4.3.4, 4.4.1 and trunk revision 151771.
Comment 2 Richard Biener 2009-09-18 08:37:54 UTC
You are getting assembler errors because it doesn't understand CFI directives.
You can use -fno-dwarf2-cfi-asm to work around the issue or update the
binutils package to something more recent.
Comment 3 Andrew Pinski 2009-09-20 21:02:15 UTC
You are using a gfortran binary which was compiled for use with a newer version of binutils than you have.  You should either install a newer version of binutils or compile gfotran yourself.
Comment 4 Norman S. Clerman 2009-09-20 23:28:18 UTC
Subject: Re:  problem compiling file

Thank you for your response. I would appreciate very much if you could you please supply me with a web site and the name of the particular version of binutils.

Thanks for your assistance.

Yours truly,

Norm

Norman S. Clerman

---- pinskia at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org> wrote: 
> 
> 
> ------- Comment #3 from pinskia at gcc dot gnu dot org  2009-09-20 21:02 -------
> You are using a gfortran binary which was compiled for use with a newer version
> of binutils than you have.  You should either install a newer version of
> binutils or compile gfotran yourself.
> 
> 
> -- 
> 
> pinskia at gcc dot gnu dot org changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|UNCONFIRMED                 |RESOLVED
>          Resolution|                            |INVALID
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41389
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.

Comment 5 Tobias Burnus 2009-09-21 07:45:10 UTC
> Thank you for your response. I would appreciate very much if you could you
> please supply me with a web site and the name of the particular version of
> binutils.

The generic place is http://www.gnu.org/software/binutils/

However, as you are seemingly using openSUSE 11.1,
  > GNU assembler version 2.19 (x86_64-suse-linux) using BFD version
  > (GNU Binutils; openSUSE 11.1) 2.19
you can go to
 http://software.opensuse.org/search?baseproject=openSUSE%3A11.1&p=1&q=binutils
and install the one from the "devel:gcc/openSUSE_11.1" repository.