public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/30677]  New: Intrinsics arguments evaluated multiple times
Date: Fri, 02 Feb 2007 08:00:00 -0000	[thread overview]
Message-ID: <bug-30677-10259@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2007-02-02  8:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-02  8:00 fxcoudert at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30677-10259@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).