This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/30677] New: Intrinsics arguments evaluated multiple times
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Feb 2007 08:00:11 -0000
- Subject: [Bug fortran/30677] New: Intrinsics arguments evaluated multiple times
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I found a case of the NCOPIES argument of the REPEAT intrinsic being evaluated
up to three times (PR30611). I remember seeing a number of other such bugs in
the past, so I wonder if we could do some general testing for that. We need to
add code to the testsuite doing things like the above code.
I don't expect to have time to do that, because it's a bit tedious (but not
very hard): it involves going through all the intrinsics declared in
intrinsic.c (look for "add_sym", starting line 920) and construct calls for
each of them, with and without their optional arguments.
$ cat evaluate_only_once_1.f90
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
program evaluate_only_once_1
implicit none
print *, abs(rfunc())
print *, abs(cfunc())
print *, repeat(sfunc(),ifunc())
contains
function lfunc() result(res)
implicit none
logical :: res
res = .true.
end function
function ifunc() result(res)
implicit none
integer :: res
res = 7
end function
function rfunc() result(res)
implicit none
real :: res
res = 1.7
end function
function cfunc() result(res)
implicit none
complex :: res
res = (1.7,-8.4)
end function
! "s" in sfunc is for "string"
function sfunc() result(res)
implicit none
character(len=5) :: res
res = "abcde"
end function
end program evaluate_only_once_1
! Each of the ?func functions should appear in the dump file the same number
! of times it appears in the main program, plus 2 (for its declaration
! and its prototype in the generated code of the main program).
!
! { dg-final { scan-tree-dump-times "lfunc" 2 "original" } }
! { dg-final { scan-tree-dump-times "ifunc" 3 "original" } }
! { dg-final { scan-tree-dump-times "rfunc" 3 "original" } }
! { dg-final { scan-tree-dump-times "cfunc" 3 "original" } }
! { dg-final { scan-tree-dump-times "sfunc" 3 "original" } }
!
! { dg-final { cleanup-tree-dump "original" } }
--
Summary: Intrinsics arguments evaluated multiple times
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fxcoudert at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30677