Internal compiler error when both using and passing an intrinsic function



Hi,

I've tried to search on Google for this issue but I can't find any simple examples matching the problem I'm having. I'm not quite sure exactly how to phrase my search to Google so I thought maybe I could get some help here.

I've brought my problem down to the minimum I can; consider the following:

SUBROUTINE MYSUB(A,F)
REAL*8 A,F
PRINT *,F(A)
END

PROGRAM TEST
IMPLICIT NONE

REAL*8 A,B
INTRINSIC DLOG

A=3D0

PRINT *,DLOG(A) ! LINE A
CALL MYSUB(A,DLOG) ! LINE B

END

If I run this through an old version of g77 (3.2.3) then the code compiles ok and gives me the output I'd expect (the natural log of 3 printed twice). The initial code (which is much more involved than the above) was written as Fortran77 which is why we're still using g77 sometimes.

If I try to use gfortran (versions given below) then I get an error message which looks like:

test2.for: In function 'MAIN__':
test2.for:14: internal compiler error: in gfc_typenode_for_spec, at fortran/trans-types.c:636
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.

I've tried with the following versions of gfortran/gcc:

gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)

(The line nuber of trans-types.c differs between the two versions.)

I've not compiled my own version but both of the above are running on fairly generic Fedora systems (FC4, FC7 and FC8 respectively). I looked at http://gcc.gnu.org/wiki/GFortran#news and didn't see anything which suggests that the issue has been addressed in versions 4.2, 4.3 or 4.4.

Interestingly, if I comment out either LINE A or LINE B the error goes away and I get the output I'd expect (in both cases the natural log of 3 printed once). This leads me to suspect that the individual lines of Fortran are valid. The problem only occurs if I both use the intrinsic function DLOG and pass it to another subroutine in the same program (it also occurs if the main program here is a subroutine).

Another thing worthy of note that it's not the "print *" causing the problem, if I try to assign the result to a variable I get the same error but I thought that using a simple "print *" gave a better example for my questions.

Which are...

1) Is what I'm trying to do valid Fortran?

2) My understanding of internal errors is that they shouldn't ever appear to the user even when the user is doing something stupid, is this correct and should I file an official bug report about this issue?

3) I can think of some work-arounds for my problem as it stands but any suggestions people have would be very welcome. My current work-around would be to write a simple wrapper function around DLOG and pass that wrapper to MYSUB.

Thank you in advance for your help.

Thanks,

Allan
.



Relevant Pages

  • Re: What is the general opinion here on creating a StackExchange Fortran site?
    ... MONITORED Google Fortran Forum just for the purpose of ... preventing the swamping by SPAM and there were volunteer monitors ... Google will remove this on 31st August. ... (there are some rather knowledgeable people on Fortran topics already ...
    (comp.lang.fortran)
  • Re: Another Fortran forum (without the spam)?
    ... persistant complainer who continues on about googlegroups but refuses ... The small amount of spam in c.l.f seems to be short bursts of online ... Via Google, there are NOT 'short bursts' of adverts but 3 or more 30- ... Fortran beginner, pointed to Google Forums, via Google itself, ...
    (comp.lang.fortran)
  • Re: Another Fortran forum (without the spam)?
    ... persistant complainer who continues on about googlegroups but refuses ... The small amount of spam in c.l.f seems to be short bursts of online ... Via Google, there are NOT 'short bursts' of adverts but 3 or more 30- ... Fortran beginner, pointed to Google Forums, via Google itself, ...
    (comp.lang.fortran)
  • Re: F200x (was Re: When to expect a F2003 compiler?)
    ... >> At the expense of following my own post, I tried Google ... The Fortran committee seems to contend that publicity ... Actually, in most industries, period, being on the first page ...
    (comp.lang.fortran)
  • Re: Complex logarithm
    ... Aris wrote: ... of a few terms gives a more accurate result than the Fortran intrinsic. ... rounds the other way, and you decide that one is more accurate. ... Also, for DLOG, VS Fortran uses an expansion in /and ...
    (comp.lang.fortran)