Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28988 Discussions

Is having a RETURN statement inside a BLOCK construct legal?

OP1
New Contributor III
332 Views

Is the following code legal Fortran 2008? I have two compilers that differ in opinion here:

BLOCK
    RETURN
END BLOCK

 

0 Kudos
2 Replies
Steven_L_Intel1
Employee
332 Views

Yes, it is.

8.1.2.2 Execution of a block

2 Execution of the block is completed when
 • the last executable construct in the sequence is executed,
 • a branch (8.2) within the block that has a branch target outside the block occurs,
 • a RETURN statement within the block is executed,
 • an EXIT statement within the block that belongs to the block or an outer construct is executed, or
 • a CYCLE statement within the block that belongs to an outer construct is executed.

0 Kudos
OP1
New Contributor III
332 Views

Thanks Steve for the clarification.

0 Kudos
Reply