public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30677]  New: Intrinsics arguments evaluated multiple times
@ 2007-02-02  8:00 fxcoudert at gcc dot gnu dot org
  2007-02-02  8:00 ` [Bug fortran/30677] " fxcoudert at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-02-02  8:00 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <bug-30677-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2012-03-03 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-02  8:00 [Bug fortran/30677] New: Intrinsics arguments evaluated multiple times fxcoudert at gcc dot gnu dot org
2007-02-02  8:00 ` [Bug fortran/30677] " fxcoudert at gcc dot gnu dot org
2010-06-11 13:17 ` fxcoudert at gcc dot gnu dot org
2010-08-26 13:07 ` fxcoudert at gcc dot gnu dot org
     [not found] <bug-30677-4@http.gcc.gnu.org/bugzilla/>
2012-03-03 13:03 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).