This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/40011] New: Problems with -fwhole-file
- From: "dominiq at lps dot ens dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 May 2009 19:52:58 -0000
- Subject: [Bug fortran/40011] New: Problems with -fwhole-file
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Summary of the problems with -fwhole-file I have found so far.
>From http://gcc.gnu.org/ml/fortran/2009-03/msg00310.html:
--------------------------------------------------------------------------------
(1) From a first look the several "Segmentation fault" are coming from
recursive functions, the simplest code being the following:
[ibook-dhum] f90/bug% cat recurs_test_1.f90
! { dg-do compile }
RECURSIVE FUNCTION eval_args(q) result (r)
INTEGER NNODE
PARAMETER (NNODE = 10)
TYPE NODE
SEQUENCE
INTEGER car
INTEGER cdr
END TYPE NODE
TYPE(NODE) heap(NNODE)
INTEGER r, q
r = eval_args(heap(q)%cdr)
END FUNCTION eval_args
[ibook-dhum] f90/bug% gfc -c -fwhole-file recurs_test_1.f90
gfc: Internal error: Segmentation fault (program f951)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
--------------------------------------------------------------------------------
(2) I have also an ICE (already reported in PR26227
http://gcc.gnu.org/ml/gcc-bugs/2009-03/msg02321.html) for
[ibook-dhum] f90/bug% cat arr_fun.f90
function test(n)
real, dimension(2) :: test
integer :: n
test = n
! print *, test
return
end function test
program arr
real, dimension(2) :: res
res = test(2)
print *, res
end program
[ibook-dhum] f90/bug% gfc -fwhole-file arr_fun.f90
arr_fun.f90: In function 'arr':
arr_fun.f90:8: internal compiler error: in fold_convert, at fold-const.c:2547
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
--------------------------------------------------------------------------------
(3) And I think the following are false positives:
[ibook-dhum] f90/bug% cat specifics_red_4.f90
subroutine test_d(fn, val, res)
double precision fn
double precision val, res
print *, fn(val), res
end subroutine
subroutine test_c(fn, val, res)
complex fn
complex val, res
print *, fn(val), res
end subroutine
program specifics
intrinsic dcos
intrinsic dcosh
intrinsic dexp
intrinsic conjg
call test_d (dcos, 1d0, dcos(1d0))
call test_d (dcosh, 1d0, dcosh(1d0))
call test_d (dexp, 1d0, dexp(1d0))
call test_c (conjg, (1.0,1.0) , conjg((1.0,1.0)))
end program
[ibook-dhum] f90/bug% gfc -fwhole-file specifics_red_4.f90
specifics_red_4.f90:25.15:
call test_d (dcos, 1d0, dcos(1d0))
1
Error: Type/rank mismatch in argument 'fn' at (1)
specifics_red_4.f90:26.15:
call test_d (dcosh, 1d0, dcosh(1d0))
1
Error: Type/rank mismatch in argument 'fn' at (1)
specifics_red_4.f90:27.15:
call test_d (dexp, 1d0, dexp(1d0))
1
Error: Type/rank mismatch in argument 'fn' at (1)
specifics_red_4.f90:29.15:
call test_c (conjg, (1.0,1.0) , conjg((1.0,1.0)))
1
Error: Type/rank mismatch in argument 'fn' at (1)
--------------------------------------------------------------------------------
>From http://gcc.gnu.org/ml/fortran/2009-03/msg00316.html
Your patch fixes some Segmentation faults (a couple), but not this one:
! { dg-do compile }
program test
interface
function bad_stuff(n)
integer :: bad_stuff (2)
integer :: n(2)
end function bad_stuff
recursive function rec_stuff(n) result (tmp)
integer :: n(2), tmp(2)
end function rec_stuff
end interface
integer :: res(2)
res = bad_stuff((/-19,-30/))
end program test
recursive function bad_stuff(n)
integer :: bad_stuff (2)
integer :: n(2), tmp(2), ent = 0, sent = 0
save ent, sent
ent = -1
entry rec_stuff(n) result (tmp)
if (ent == -1) then
sent = ent
ent = 0
end if
ent = ent + 1
tmp = 1
if(maxval (n) < 5) then
tmp = tmp + rec_stuff (n+1)
ent = ent - 1
endif
if (ent == 1) then
if (sent == -1) then
bad_stuff = tmp + bad_stuff (1)
end if
ent = 0
sent = 0
end if
end function bad_stuff
--------------------------------------------------------------------------------
>From http://gcc.gnu.org/ml/fortran/2009-03/msg00317.html
A simpler test:
recursive function fac(i) result (res)
integer :: i, j, k, res
k = 1
goto 100
entry bifac(i,j) result (res)
k = j
100 continue
if (i < k) then
res = 1
else
res = i * bifac(i-k,k)
end if
end function
program test
external fac
external bifac
integer :: fac, bifac
print *, fac(5)
print *, bifac(5,2)
print*, fac(6)
print *, bifac(6,2)
print*, fac(0)
print *, bifac(1,2)
end program test
--------------------------------------------------------------------------------
>From http://gcc.gnu.org/ml/fortran/2009-04/msg00031.html
some ICEs on the polyhedron test suite (see also pr39896):
[ibook-dhum] lin/test% gfc -fwhole-file aermod.f90
f951: internal compiler error: Bus error
[ibook-dhum] lin/test% gfc -fwhole-file air.f90
f951: internal compiler error: Bus error
[ibook-dhum] lin/test% gfc -O0 -fwhole-file gas_dyn.f90
[ibook-dhum] lin/test% gfc -O1 -fwhole-file gas_dyn.f90
gas_dyn.f90: In function 'eos':
gas_dyn.f90:360: internal compiler error: Bus error
[ibook-dhum] lin/test% gfc -O2 -fwhole-file gas_dyn.f90
gas_dyn.f90: In function 'readin':
gas_dyn.f90:1572: internal compiler error: Bus error
[ibook-dhum] lin/test% gfc -O3 -fwhole-file gas_dyn.f90
gas_dyn.f90: In function 'nozzle':
gas_dyn.f90:896: internal compiler error: Bus error
Note that for gas_dyn.f90, there is no ICE at -O0 while
with nonzero optimization, the ICEs occur in different
places.
--
Summary: Problems with -fwhole-file
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dominiq at lps dot ens dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40011