- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
block integer :: a = 1 block integer :: a = 2 print *, a end block print *, a end blockThis is fine. Now I give a name to the blocks, and I choose the same name. For this, a third block is required which allows me to use the name again.
aName: block integer :: a = 1 block aName: block integer :: a = 2 print *, a end block aName end block print *, a end block aNameThis time, the output is 1, 1, and by looking at the assembler output, the compiler indeed assigns the very same position in memory to the two variables a. If, instead of using the initialization statement, I directly set the values to 1 and 2 after declaration, the output is 2, 2. The problem is not caused by the third block, but by the double names. Compiler: Visual Fortran Compiler 17.0.2.187
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can reproduce this and reported it to Development. It is the use of the same name that leads to the incorrect results. Unique names avoids the issue.
(Internal tracking id: CMPLRS-42483)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Development informs me the program is invalid and that ifort should have issued an error regarding a duplicate construct name, ANAME.
They indicate that Construct names (which is what aName is in this routine) are local identifiers.
In section 19.1 of the draft F2015 standard, it states:
2 The scope of
6 • a local identifier is an inclusive scope,
and under the section "Terms and Definitions", 3.90, it defines inclusive scope as:
11 inclusive scope
12 nonblock scoping unit plus every block scoping unit whose host is that scoping unit or that is nested within such
13 a block scoping unit
NOTE 3.5
That is, inclusive scope is the scope as if BLOCK constructs were not scoping units.
Thus, 2 BLOCKs within the same routine cannot have the same construct name (aName).
ifort will be made to issue an appropriate error in the future.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page