Bug 39253 - A bug with interface in gfortran
Summary: A bug with interface in gfortran
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-20 04:35 UTC by Sergiy Bubin
Modified: 2009-02-20 08:05 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 Sergiy Bubin 2009-02-20 04:35:25 UTC
This is my first report at gcc Bugzilla...

I tried to compile a fortran program that invokes QD library (multiprecision arithmetic, available at http://www.cs.berkeley.edu/~yozo/software/qd-2.3.7.tar.gz). When I use Intel compiler suite, everything is fine. If I switch to gcc (the performance of QD is much better when it is compiled with g++ rather than Intel C++) then I get the following error message:

In file f_main.f90:17

call random_number(s)
                    1
Error: There is no specific subroutine for the generic 'random_number' at (1)
make: *** [f_main.o] Error 1

I have investigated the issue a little it and came to the conclusion that there is something wrong with interfacing in gfortran. The QD library has fortran modules called ddmod.f90 and qdmod.f90 which contain the following:

  interface random_number
    module procedure ddrand
  end interface

  interface random_number
    module procedure qdrand
  end interface

random_number is interfaced to allow it to be called with the types or real numbers implemented in QD [type(qd_real) and type(dd_real)]. But in my code I want to call random_number with standard real(8) type. Intel fortran has no problems with it, the compilation goes fine and the program runs as expected. So there must be a bug in gfortran.

In order to make things work I simply removed those interfaces from qdmod.f90 and ddmod.f90 (I don't need random_number with type(qd_real) and type(dd_real) anyway). After doing that everything goes fine.
Comment 1 Tobias Burnus 2009-02-20 07:00:51 UTC
Thanks for the report. However, GCC/gfortran 4.1.0 is quite old. (GCC 4.0.0 was the first version which contained gfortran, which was at that time very buggy. Version 4.1.x was quite usable, but still contained a few bugs (especially 4.1.0).)

Could you update to a newer version?

4.2.x is much better than 4.1.x, but the recommended version is either 4.3.3 (latest stable version) or 4.4 (latest developer version, which should be soon released). You might try a build at http://gcc.gnu.org/wiki/GFortranBinaries
Comment 2 Sergiy Bubin 2009-02-20 08:05:50 UTC
It looks like this bug has been fixed since version 4.1. I tried to compile the code with a newer version of gfortran, 4.3.2, and everything went fine. Apologies for a wrong alarm.