Bug 50376 - pure procedure allows assignment to iterator variable in array constructor
Summary: pure procedure allows assignment to iterator variable in array constructor
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-09-13 08:57 UTC by Vittorio Zecca
Modified: 2013-07-15 06:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
just compile it (152 bytes, text/plain)
2011-09-13 08:57 UTC, Vittorio Zecca
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2011-09-13 08:57:37 UTC
Created attachment 25255 [details]
just compile it

gfortran must allow in a PURE procedure assignment to iterator variable in array constructor
Comment 1 Tobias Burnus 2011-09-13 09:54:27 UTC
The constraint leading the rejection is the following (C1283) - though having a variable in as ac-do-variable is something different (cf. 16.4).

Other compilers also accept the program

F2008 for quotes:

"C1283    In a pure subprogram any designator with a base object that
          is in common or accessed by host or use association, is a dummy
          argument with the INTENT (IN) attribute, is a coindexed object, or
          an object that is storage associated with any such variable, shall
          not be used
   (1) in a variable denition context (16.6.7),
   (2) as the data-target in a pointer-assignment-stmt,
   (3) as the expr corresponding to a component with the POINTER attribute
       in a structure-constructor,
   (4) as the expr of an intrinsic assignment statement in which the variable
       is of a derived type if the derived type has a pointer component at
       any level of component selection, or
   (5) as an actual argument corresponding to a dummy argument with
       INTENT (OUT) or INTENT (INOUT) or with the POINTER attribute."


"16.4 Statement and construct entities"
"A variable that appears as a data-i-do-variable in a DATA statement or an ac-do-variable in an array constructor,
as a dummy argument in a statement function statement, or as an index-name in a FORALL statement is a statement entity. A variable that appears as an index-name in a FORALL or DO CONCURRENT or as an associate-name in a SELECT TYPE or ASSOCIATE construct is a construct entity. [...]"

"The name of a statement entity shall not be the same as an accessible global identier or local identier of class (1) (16.3.1), except for a common block name or a scalar variable name. Within the scope of a statement entity, another statement entity shall not have the same name."

"The name of a data-i-do-variable in a DATA statement or an ac-do-variable in an array constructor has a scope of its data-implied-do or ac-implied-do. It is a scalar variable that has the type and type parameters that it would have if it were the name of a variable in the innermost executable construct or scoping unit that includes the DATA statement or array constructor, and this type shall be integer type; it has no other attributes. The appearance of a name as a data-i-do-variable of an implied DO in a DATA statement or an ac-do-variable in an array constructor is not an implicit declaration of a variable whose scope is the scoping unit that contains the statement."
Comment 2 Vittorio Zecca 2013-07-14 23:38:53 UTC
I believe this has been fixed in gfortran 4.8.1
Comment 3 Tobias Burnus 2013-07-15 06:45:57 UTC
I believe this has been fixed in GCC 4.8 by the patch for PR54958.

Close as FIXED.