(j3.2006) Multiple & on free-form continuation?

Bill Long longb
Wed Aug 27 15:28:33 EDT 2014


On Aug 27, 2014, at 1:57 PM, Lionel, Steve <steve.lionel at intel.com> wrote:

> Ian Harvey sent me the following amusing source:
>  
>   PRINT "(A)", 'There is something ' & &
>     // 'wrong with this statement.'
> END
>  
> and noted that Intel Fortran failed to diagnose this as an error. I can read the words in the standard as not disallowing this. 3.3.2.4 says:
>  
> If a noncharacter context is to be continued, an "&" shall be the last nonblank character on the line, or the last nonblank character before an "!".
>  
> An & is the last nonblank character, just not the only &. I don?t see any words that prohibit multiple ?&? characters at the end of a continued line.
>  
> gfortran doesn?t like this one.


The Cray and PGI compilers also reject this.  The Cray parsing: The final & on the first line is the continuation sentinel. What comes before that, including the first &,  is part of the io-list of the print statement.   But ?There is something ? & ?wrong with this statement.? is not valid syntax for a character expression.  Message: Unexpected syntax while parsing the PRINT statement.

PGI took the opposite approach and assumed the first & was the continuation sentinel, and objected to non-comment text on the line after the &.  Message:  Non-comment character after a '&? .   

I?m biased toward the Cray message, but either way this is not conforming code. 


>  
> Also interesting:
>  
>   PRINT "(A)", "Is there something & &
> & wrong with this statement?"
>  
> Intel Fortran accepts this and treats the first & as an ordinary character ? gfortran does the same, and I think I can justify this from the text in paragraph 4.

This one is fine.  The character constant itself is continued across the line break and has the value ?Is there something &  wrong with this statement??.   Single io-list item with valid syntax. 

>  
> Is the first case interp fodder?

I don?t think so.

Cheers,
Bill

>  
> Steve Lionel
> Intel Developer Support
> Merrimack, NH
>  
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Suport  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list