Error #5508 - Conflict with previous declaration

Error #5508 - Conflict with previous declaration

Imagen de jirina

I started using IVF Composer XE 2013 Update 2 today and I am not able to compile and link my application, because I started getting Error #5508 - Conflict with previous declaration. In one of my (fixed form) source files I have a function

logical*4 function use_SCGS_3D ( i, j, scgs2 )

with i and j defined as integer*4 and scgs2 defined as integer*4 scgs2(nx,ny) (nx, ny are taken from a common).

In another source file, I have a subroutine that calls this function, so I defined

logical*4 use_SCGS_3D

in that subroutine.

I double checked that the function is not used anywhere but in the single, above mentioned subroutine.

I uninstalled Update 2 and installed Update 1 and my application is compiled and linked without any problems. I uninstalled Update 1, installed Update 2, and the problem occured again, so I assume it is something in Update 2, causing this problem. Since I can attach the code, I will try narrowing it down to a simple example, hoping that the problem persists.

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

In your sub -program where the function is called try the declaration

logical(4) , external ::   use_SCGS_3D

Imagen de mecej4

Please report both the original declaration and the second one -- the one that the compiler complains about.

...scgs2 defined as integer*4 scgs2(nx,ny) (nx, ny are taken from a common)

You cannot use variables in COMMON in array declarations. One reason is that the values of such variables are not necessarily known at compile time. Another is that the values may change during program execution.

Imagen de jirina

Things are weird - I tried various combinations of installed versions of Composer XE 2013 - Update 1 only, Update 1 and 2, and Update 2 only. I currently have just Update 2 after uninstalling Update 1, and when I tried Rebuild, Batch Rebuild, and separate Clean and then Build, the error does not occur anymore... I don't know what could happen, probably something wrong with the original and even reinstalled Update 2 during my previous attempts.

Imagen de jirina

Quote:

mecej4 wrote:

You cannot use variables in COMMON in array declarations. One reason is that the values of such variables are not necessarily known at compile time. Another is that the values may change during program execution.

I know that nx, ny are fixed during my application's run, initialized when the application is starting. The reason is that I am allocating many 3D real arrays in the main program ( real(4), allocatable :: Fx(:,:,:) ) and I am then passing them to subroutines that pass them to other subroutines - I was not able to find a better way than this silly one to pass allocatable fields.

Imagen de jimdempseyatthecove

real(4) function Foo(Fx)
implicit none
real(4) :: Fx(:,:,:)
... ! other declarations and code here
end function Foo

--------------------------

module YourInterfaces
interface
real(4) function Foo(Fx)
implicit none
real(4) :: Fx(:,:,:)
end function Foo
end interface

--------------------------------

subrouting HuYa(...
use YourInterfaces
implicit none
...
    x = Foo(SomeFx)

Jim Dempsey

www.quickthreadprogramming.com
Imagen de Repeat Offender

Quote:

mecej4 wrote:

Please report both the original declaration and the second one -- the one that the compiler complains about.

...scgs2 defined as integer*4 scgs2(nx,ny) (nx, ny are taken from a common)

You cannot use variables in COMMON in array declarations. One reason is that the values of such variables are not necessarily known at compile time. Another is that the values may change during program execution.

You darned well can use variables in COMMON in array declarations. You can even use them in specification inquiries that are part of constant expressions when it makes sense.

Imagen de mecej4

R.O.: Here are a couple of examples that produce compile time errors. I realize that one can declare automatic arrays with sizes specified using scalar integers that are in COMMON, nor do I know the exact types of array declarations that the OP used. Example-1:


subroutine sub()

implicit none

integer n, a

common /dim/n

common /ablk/a(n)
write(*,*)a
end subroutine sub


Example-2:
subroutine sub(n)

implicit none

integer n, a

common /ablk/a(n)
write(*,*)a
end subroutine sub

Both these cause the compiler to say:

error #6756: A COMMON block data object must not be an automatic object. [A] 

Imagen de Repeat Offender

Quote:

mecej4 wrote:

Both these cause the compiler to say:error #6756: A COMMON block data object must not be an automatic object. [A]

But those examples have nothing to do with your statements or the original post, which is possibly caused by function use_SCGS_3D being in a module so that its interface is already explicit in the intended caller. The type definition statement for its result variable would then be a #5508. Maybe this could be caused by /check:interface + compiler bug as well.

Imagen de jirina

I've got some news regarding my problem with the error #5508 - my application is compiled only in the Debug configuration, both both 32-bit and 64-bit systems, but the Release configuration fails - I still get the error #5508 with compilers from Update 2, while compilers from Update 1 are able to compile the code.

I tried following:

  1. I still have the function logical*4 function use_SCGS_3D in one (fixed form) source file.
  2. In another source file, I call the function from 1., so I declare logical*4 use_SCGS_3D.
  3. I tried changing the declaration from 2. to logical(4), external :: use_SCGS_3D, but I still get the error "error #5508: Declaration of routine 'USE_SCGS_3D' conflicts with a previous declaration ...". The error is issued for the line with the statement from 1., even though I double checked that this name is not used anywhere else in the whole project.

Does anybody have any ideas what I could try to get rid of this error before I start my attempts to reduce the code so that it can be attached and it still generates the error?

Imagen de app4619

Do a global search in the VS for USE_SCGS_3D (edit, Find  & Replace, Quick Find.  Ensuring 'entire solution' is in the what to search box.

This will search all files to see if you have any other declaration that conficts.

Failing that for a quick fix try renaming the function in the 2 places you know to say zz123_USE_SCGS_3D and see what happens!

 

Imagen de jirina

I searched for the problematic name again, even using other tools than Visual Studio, and could not find anything. I also tried renaming the function to app3D and the problem still persists. But just with Update 2, not in Update 1.

Imagen de Steve Lionel (Intel)

Does turning off generated interface checking make the problem go away?  Can you provide us a zip of a project that shows the problem?

Steve
Imagen de jirina

Indeed, turning off the compiler option /warn:interfaces makes the problem go away. Thank you!

I cannot provide the full project; would you still be interested if I tried reducing the project so that it can be provided and the problem is still there?

Imagen de Steve Lionel (Intel)

Yes, certainly.

Steve
Imagen de jirina

Unfortunately, reducing the project resulted in compiling and linking the application without any problems even with /warn:interfaces enabled. I will try a not so strict reduction; it is a shame I am not allowed to provide the full code.

Inicie sesión para dejar un comentario.