Renaming of module variables to existing variable name does *not* produce an error

Renaming of module variables to existing variable name does *not* produce an error

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.

publicaciones de 15 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

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

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

 

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

A specific code example from the OP would be helpful; in particular, the use of the PARAMETER attribute needs to be clarified.

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...

mecej4:

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

Please show us an example that gets the error. Feel free to modify Lorri's example to match yours.

Steve - Intel Developer Support

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.

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...."

Cita:

app4619 escribió:

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?

Dunno, I used "Compiling with Intel(R) Visual Fortran Compiler XE 13.1.3.198 [IA-32]"  what level are you using?

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.

Steve - Intel Developer Support

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]

The buildlog will among other things shown which options were used to allow someone else to try the replicate the problem.

Here is the BuildLog.htm from a build in debug config. (had to rename it to upload)

Adjuntos: 

AdjuntoTamaño
Descargar debug.log8.12 KB

Please attach the source file you used.

Steve - Intel Developer Support

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya