PING: [patch, fortran] PR 27997: Implement F2003-style array constructor with typespec

FX fxcoudert@gmail.com
Fri Apr 25 14:06:00 GMT 2008


>>   write *, [ character(len=1) :: "I am too long", "me too" ]
> I fail to see why this should fail. I think this is perfectly valid  
> and equivalent to ['I', 'm']; the point of the constructor is too  
> allow items which have different lengths. If they had all the same  
> length, there were no need for the typespec (in this case).

I apologize, I thought it was only possible to pad, not to reduce  
length. (The standard only shows one example, and it is extending  
length.)

>>   write *, [ integer(4) :: huge(0_8) ]
> I think one could add a range check here; with -fno-range-check it  
> should compile (and give with -Wconversion a warning), but with - 
> frange-check (= default) a overflow error should be printed.

The range check is already performed, I'm just asking for a testcase  
to be added.

>> And constructors withing constructors, like this:
>>   print *, [ integer(kind=8) :: 4, [ integer(kind=4) :: 42, 12 ] ]
>>   print *, [ character(len=8) :: "foo", [ character(len=4) ::  
>> "bar", "gee" ] ]
> I think this fails currently - at least for strings, possibly also  
> with -fbounds-check and other types; cf. PR35846. I think one  
> problem are global variables. Note the test case in the PR is  
> without typespecs.

I've also tested it before sending, and the example above currently  
works.

> My suggestion is to get this patch in first and fix then the nested  
> constructors for inclusing typespec. One probably should add your  
> tests to the PR.

I don't understand: the testcases I've added *work*, I'm just asking  
for testcases.

> Note also that there is in the Fortran 2003 standard the following  
> example:
>   (/ CHARACTER(LEN=7) :: ’Takata’, ’Tanaka’, ’Hayashi’ /)
> which has a similar "problem": The first two names are too short.  
> Without the typespec the example were invalid  as then all items  
> have to have the same length.

See above, I thought only padding was possible, I stand corrected  
(thanks Tobias!).

FX

-- 
François-Xavier Coudert
http://www.homepages.ucl.ac.uk/~uccafco/



More information about the Fortran mailing list