- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I accedentally renamed a module variable (a parameter actually) to a name that also existed in the same module; I guess this should have produced an error, but it didn't.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I understand your program correctly, it was something like this:
module foo
integer, parameter :: limit=25
integer :: outer_limit = 10
end module foo
program main
use foo, only: limit => outer_limit
print *, limit !! prints 10
end
Interestingly enough, this is legal. There is a lot of leeway in renaming variables from modules, including reusing names that exist in the module.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did not infer from the original description that the USE statement should contain a "only:" clause. Removing that from Lorri's test program and compiling with the 14.0.0.103 compiler gives the helpful message
[fortran]only.f90(6): error #7837: Two or more accessible entities, other than generic interfaces,
may have the same name only if the name is not used to refer to an entity in the scoping unit. [LIMIT]
use foo, limit => outer_limit
[/fortran]
A specific code example from the OP would be helpful; in particular, the use of the PARAMETER attribute needs to be clarified.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your example has an ONLY clause which makes it work, I didn't have that.
Do you mean that this is legal according to the sandard, or according to the compiler? It seems strange if it was allowed in the standard as it produces ambiguities unless the renaming happens after an ONLY clause...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Lorri's example is essentially similar to mine, except for her ONLY clause.
I did not get that error message. I'm using the XE 2013 compiler without SP1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please show us an example that gets the error. Feel free to modify Lorri's example to match yours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
module foo
integer, parameter :: limit=25
integer :: outer_limit = 10
end module foo
program main
use foo, limit => outer_limit !no 'only:'
print *, limit !! prints 25
end
This program induces the assumed bug (i.e. that no error is reported) for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The above sample gives "error #7837: Two or more accessible entities, other than generic interfaces, may have the same name only if the name is not used to refer to an entity in the scoping unit. [LIMIT] compilation aborted for C:\Users\An...."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
app4619 wrote:
The above sample gives "error #7837: Two or more accessible entities, other than generic interfaces, may have the same name only if the name is not used to refer to an entity in the scoping unit. [LIMIT] compilation aborted for C:\Users\An...."
Strange, but I don't get that message... Could it be because I don't have the latest SP?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dunno, I used "Compiling with Intel(R) Visual Fortran Compiler XE 13.1.3.198 [IA-32]" what level are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I went back as far as 12.1 and still saw the error. Please show us a full build log (command line best, but buildlog.htm from VS would do) showing what you saw.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess there isn't much to see in the build log as nothing in particular is reported. The only problem is that the result, i.e. when printing the value is wrong. The version is 13.0.1.119 [IA-32]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The buildlog will among other things shown which options were used to allow someone else to try the replicate the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please attach the source file you used.

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