This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/27996] Compile time warn for: character(2) :: str = 'ABC' (expression truncated)



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]