public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33759]  New: Unequal character lengths in MERGE intrinsic not detected in contained function.
@ 2007-10-12 20:30 dominiq at lps dot ens dot fr
  2007-10-12 20:54 ` [Bug fortran/33759] Unequal character lengths in MERGE intrinsic not detected at run time burnus at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-10-12 20:30 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-11-15  4:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-12 20:30 [Bug fortran/33759] New: Unequal character lengths in MERGE intrinsic not detected in contained function dominiq at lps dot ens dot fr
2007-10-12 20:54 ` [Bug fortran/33759] Unequal character lengths in MERGE intrinsic not detected at run time burnus at gcc dot gnu dot org
2007-10-12 22:18 ` dominiq at lps dot ens dot fr
2007-10-23 15:52 ` pault at gcc dot gnu dot org
2007-10-23 16:08 ` pault at gcc dot gnu dot org
2007-10-24 11:36 ` dominiq at lps dot ens dot fr
2007-10-25  9:49 ` dominiq at lps dot ens dot fr
2007-11-12 15:03 ` pault at gcc dot gnu dot org
2007-11-12 15:34 ` pault at gcc dot gnu dot org
2007-11-12 16:48 ` dominiq at lps dot ens dot fr
2007-11-13 12:46 ` pault at gcc dot gnu dot org
2007-11-19  7:44 ` [Bug fortran/33759] ICE in transfer_simplify_4.f90 at any level of optimization pault at gcc dot gnu dot org
2008-02-26 12:45 ` pault at gcc dot gnu dot org
2008-03-04 23:48 ` fxcoudert at gcc dot gnu dot org
2008-10-21  6:30 ` pault at gcc dot gnu dot org
2008-11-12 17:04 ` jakub at gcc dot gnu dot org
2008-11-13 11:25 ` pault at gcc dot gnu dot org
2008-11-15  4:03 ` rguenth at gcc dot gnu dot 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).