From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29596 invoked by alias); 12 Oct 2007 20:30:33 -0000 Received: (qmail 29566 invoked by uid 48); 12 Oct 2007 20:30:22 -0000 Date: Fri, 12 Oct 2007 20:30:00 -0000 Subject: [Bug fortran/33759] New: Unequal character lengths in MERGE intrinsic not detected in contained function. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dominiq at lps dot ens dot fr" 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-10/txt/msg01270.txt.bz2 In my comment 31 of PR31608, I have questionned the validity of the test case in comment 28. Now I think the test is invalid, but not detected. First consider the code: character(len=20) :: string character(len=1) :: tmp(20) string = "" tmp = "" tmp = transfer(string,"x",len(string)) tmp = merge(tmp, string, .true.) end gfortran gives: tmp = merge(tmp, string, .true.) 1 Error: Unequal character lengths (1 and 20) in MERGE intrinsic at (1) Note that an error based on the shape would probably better. When using arrays of real, I get: Error: Different shape for arguments 'tsource' and 'fsource' for intrinsic 'merge' at (1) on dimension 1 (3 and 2) Now consider the code character(len=1) :: string = "z" character(len=20) :: tmp = "" tmp = Upper ("abcdefg") print *, "'", tmp, "'" contains Character (len=20) Function Upper (string) Character(len=*) string character(len=1) :: tmp(20) = "" tmp = transfer(string,"x",len(string)) tmp = merge(tmp, string, .true.) Upper = transfer(tmp, "x") return end function Upper end gfortran compiles it without complain and gives 'a ' I think the above code is invalid in two counts: (1) transfer(string,"x",len(string)) is a rank one array of size 7 and should not be assigned to an array of size 20. I think this is quite difficult to detect at compile time, but it would be nice to have it at runtime. (2) merge(tmp, string, .true.) try to merge a rank one character array with a rank zero string. If this invalid and detected in the first test above, it should also be detected in the function, unless I am missing something. -- Summary: Unequal character lengths in MERGE intrinsic not detected in contained function. Product: gcc Version: 4.3.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 GCC build triplet: powerpc-apple-darwin8 GCC host triplet: powerpc-apple-darwin8 GCC target triplet: powerpc-apple-darwin8 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33759