Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28655 Discussions

Bug Compiler 11.0? Pointer assignment

bucky83
Beginner
618 Views

Hi, I think i got a problem here.

I have a Dynamical Data Type defined as:

[cpp]

TYPE D_I_V

INTEGER, DIMENSION(:), POINTER :: vec => NULL()

END TYPE D_I_V




[/cpp]

If I Run a program which involves the sequent subroutine:

[cpp]SUBROUTINE try_pointer( a )

  IMPLICIT NONE

  TYPE(D_I_V), DIMENSION(:), INTENT(IN)         :: a

  INTEGER, DIMENSION(:),POINTER :: jj => NULL()

  INTEGER :: i


  DO i = 1,size(a);

    jj => a(i)%vec

    write(*,*) ASSOCIATED(jj)

  ENDDO

END SUBROUTINE try_pointer[/cpp]

I get a sequence of FALSE, since the pointer "jj" is not associated to "a(i)%vec".

Clearly the bug is in the assignement "jj => a(i)%vec" which in fortran intel compiler 10.0 worked fine, But here must be substituted by "jj => a(i)%vec(:)",

Do you know if I made any error or is it some kind of bug!?
I remind you, that inserting some code (like WRITE this or WRITE that) into the SUBROUTINE, which obviously doesn't touch the variables, the association seems to work fine!!!

I'm really freaking you!

Thanks


DARIO

0 Kudos
8 Replies
reinhold-bader
New Contributor II
618 Views

Hello,

you haven't shown us how exactly you set up your program. Since the default initialization for the component is NULL(), any not explicitly allocated or associated entities will be unassociated. For example the program

program arptr
use mod_arptr
implicit none
type(d_i_v) :: y(5)
allocate(y(2)%vec(7))
call try_pointer(y)
deallocate(y(2)%vec)
end program arptr

when used together with your code, results in

F
T
F
F
F
when using Intel 10.1, and

F
F
F
F
F

when using Intel 11.0. I guess there is indeed a bug in V11 :-)

0 Kudos
bucky83
Beginner
618 Views
Yes, I intentionally skipped that part since the program is well constructed.
The input vector (to be pointed) is indeed correctly allocated and assigned. I get FALSE while using directly the TARGET array a get a TRUE value.

By any chance I post here an example code.
[cpp]PROGRAM example

TYPE(D_I_V), DIMENSION(4) :: B
INTEGER :: i

DO i = 1,4

ALLOCATE( B(i)%vec(3) )
B(i)%vec = i * (/1, 2, 3/)

ENDDO

CALL try_pointer(B)

PROGRAM example
[/cpp]



The program output is FALSE instead of TRUE, which is clearly the correct one.
0 Kudos
Steven_L_Intel1
Employee
618 Views

I can reproduce this. Curiously, on Windows at least (where I tried it), simply enabling debug symbols (even with optimization) makes the problem go away. I will report it to the developers.

0 Kudos
bucky83
Beginner
618 Views

Can I ask you what kind of debug tools did you used?

I'm under linux, but at least I can give it a shot.
Thanks

DARIO

0 Kudos
Steven_L_Intel1
Employee
618 Views

No tools - just used the compiler option to generate debug symbols. "-debug full" on Linux.

0 Kudos
Steven_L_Intel1
Employee
618 Views

Entered as DPD200110352. Turning off optimization (-Od) may be the better workaround.

0 Kudos
bucky83
Beginner
618 Views
At the moment I've replaced every assigment like:
[cpp]a => b % struct[/cpp]

to

[cpp]a => b % struct(:)[/cpp]

I will try to completely disable optimization anyway, just for the moment. Do you think that this kind of issue will be fixed soon?

Thank you.
Dario.
0 Kudos
Steven_L_Intel1
Employee
618 Views

The issue is just starting investigation so I can't speculate on a timeframe for the fix.

0 Kudos
Reply