public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27998]  New: character arrays: warn if erray constructor values have different lengths
@ 2006-06-12 13:21 tobias dot burnus at physik dot fu-berlin dot de
  2006-06-13 17:45 ` [Bug fortran/27998] " pault at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-06-12 13:21 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

The following constructor seems to be invalid according to the Fortran 2003
standard:
  (/ 'Takata', 'Tanaka', 'Hayashi' /)
as first two strings are 6 whereas the last one is 7 character long.

NAG f95 fails with the following error:
Error: string.f90, line 3: Array constructor values have differing CHARACTER
lengths (6 and 7)
[f95 error termination]

Thus a warning would be nice, at least with -Wall, maybe even a default
warning.

In the Fortran 2003 standard, I cannot find the line which forbids the usage of
different length strings. However, in "NOTE 4.70" of implicitly states that it
is not allowed:

"An example of an array constructor that specifies a nonkind type parameter:
   (/ CHARACTER(LEN=7) :: ’Takata’, ’Tanaka’, ’Hayashi’ /)
In this constructor, without the type specification, it would have been
necessary to specify all of the constants with the same character length."

(This currently does not work in gfortran, see bug 27997.)

Example:
----------------------------
program test
  character(15) :: a(3)
  ! invalid as the constants have different character lengths
  a =  (/ 'Takata', 'Tanaka', 'Hayashi' /)
  ! This is valid Fortran 95/2003
  !a =  (/ 'Takata ', 'Tanaka ', 'Hayashi' /)
  ! And this is valid Fortran 2003
  !a = (/ character(len=7) :: 'Takata ', 'Tanaka ', 'Hayashi' /)
  print '(a)',a
end program test


-- 
           Summary: character arrays: warn if erray constructor values have
                    different lengths
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot burnus at physik dot fu-berlin dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27998


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

end of thread, other threads:[~2007-01-14 14:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-12 13:21 [Bug fortran/27998] New: character arrays: warn if erray constructor values have different lengths tobias dot burnus at physik dot fu-berlin dot de
2006-06-13 17:45 ` [Bug fortran/27998] " pault at gcc dot gnu dot org
2006-06-15  6:35 ` paul dot richard dot thomas at cea dot fr
2006-06-15 12:34 ` tobias dot burnus at physik dot fu-berlin dot de
2006-06-30 13:13 ` paul dot richard dot thomas at cea dot fr
2007-01-05 14:46 ` pault at gcc dot gnu dot org
2007-01-14 14:51 ` [Bug fortran/27998] [4.2 and 4.1 only] " pault at gcc dot gnu dot org
2007-01-14 14:53 ` [Bug fortran/27998] [4.1 " pault 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).