From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5377 invoked by alias); 2 Feb 2007 08:00:25 -0000 Received: (qmail 5129 invoked by uid 48); 2 Feb 2007 08:00:11 -0000 Date: Fri, 02 Feb 2007 08:00:00 -0000 Subject: [Bug fortran/30677] New: Intrinsics arguments evaluated multiple times X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "fxcoudert at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-02/txt/msg00130.txt.bz2 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