This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/27996] Compile time warn for: character(2) :: str = 'ABC' (expression truncated)
- From: "tobias dot burnus at physik dot fu-berlin dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jun 2006 13:01:06 -0000
- Subject: [Bug fortran/27996] Compile time warn for: character(2) :: str = 'ABC' (expression truncated)
- References: <bug-27996-1719@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from tobias dot burnus at physik dot fu-berlin dot de 2006-06-23 13:01 -------
Additional remarks (which I forget to make):
Both cases are valid Fortran as:
(1) If the length of 'variable' is less than that of 'expr', the value of
'expr' is truncated from the right until it is the same length as the
'variable'.
(2) If the length of 'variable' is greater than that of 'expr', the value of
'expr' is extended on the right with blanks until it is the same length as
the variable.
However, I still think it is useful to give a compile-time warning. This for
example should produce a warning:
----------------------------------------
program test
character(20),parameter :: path = 'mypath/'
character(20),parameter :: file = path // 'myfile.txt'
print *, trim(file)
end program test
----------------------------------------
whereas using "trim(path) // 'myfile.txt'" should not.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27996