[gfortran] Fix PR14067

Paul Brook paul@codesourcery.com
Sun May 30 18:06:00 GMT 2004


On Sunday 30 May 2004 16:36, Bud Davis wrote:
> On Sun, 2004-05-30 at 10:24, Tobias Schlüter wrote:
> > Paul Brook wrote:
> > >>2004-05-30  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
> > >>
> > >>	* trans-const.c (gfc_conv_string_init): Allow variable string
> > >>	length lower than initialization string length.
> > >
> > > Ok. Please also change the comment to read "padded or truncated to the
> > > correct length".
> >
> > Bud privately pointed out to me that this is invalid code. If we want to
> > accept this code as an extension, I can still commit this patch, but I
> > will try to find the right place in the frontend to emit a warning or an
> > error, respectively. Right now the resolution of DATA statements is
> > somewhat mysterious to me.
>
> invalid is a strong word...i just know that if i write code like this:
>           character*2 animal
>           data animal /'cat'/
>
> it is probably a mistake and i would like to know about it as early as
> possible.  the standard may say "silently truncate", i don't know.

Initialization follows the same rules as a normal assignment, ie. the value 
should be truncated. See sections 5.1 and 7.5.1.4 of the f95 standard.

IMHO this is "Suspicious" code, and should come under -Wsurprising.

Paul



More information about the Gcc-patches mailing list