http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54597
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Last reconfirmed| |2012-09-16 CC| |burnus at gcc dot gnu.org Ever Confirmed|0 |1 --- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-09-16 12:36:39 UTC --- I think your test case is wrong; I sincerely doubt that your test case matches what you have actually used. However, there is a bug which matches your description. This bug has been solved in GCC 4.8 but it does exist in GCC 4.7.x. (GCC 4.8 is the current developer version of GCC, see http://gcc.gnu.org/wiki/GFortranBinaries for information about how to build it yourself or where to obtain unofficial builds of it.) But back to your test case: function foo() character(*), allocatable :: foo The "*" is invalid in this context; it means that the length is assumed - but there is nothing from where it can be assumed. You have to use ":" (deferred length) instead of "*". Additionally, you need to use TRIM in bar = "abc" foo = TRIM(bar) In that case, the result is the expected "abc" (in GCC 4.8; as written, 4.7 has a bug). Without TRIM the correct result is "abc followed by 997 blanks and then the tailing ". (With GCC 4.7, the result with TRIM is - wrongly - the same as with TRIM.)