|
| View previous topic :: View next topic |
| Author |
Message |
Keith Refson
Joined: 10 Jul 2006 Posts: 10
|
Posted: Wed Oct 10, 2012 1:49 am Post subject: Incorrect behaviour with --Mchkptr |
|
|
I have some code which when compiled with options -C -Mchkptr returns the diagnostic abort
0: Null pointer for x%p (pgi_check.f90: 21)
I see no indication in Metcalfe, Reid and Cohen's book that it is an error to call "associated" with a null pointer. Surely it ought simply to return .FALSE.
The diagnostic abort only occurs for the two-argument form of the "associated"
intrinsic. IIt alsogoes away if the pointeris not a member of a derived type.
I think this is a bug and the diagnostic is incorrect - but am willing to be corrected.
| Code: |
module m
integer,save,pointer :: x,y
contains
subroutine init(x,y)
integer,pointer, intent(inout) :: x,y
nullify(x)
nullify(y)
end subroutine init
subroutine check_assoc
if( associated(x,y) ) then
write(*,*) "Yes"
else
write(*,*) "No"
end if
end subroutine check_assoc
end module m
program assoc_test
use m
nullify(x)
nullify(y)
call init(x,y)
call check_assoc
end program assoc_test
|
|
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Wed Oct 10, 2012 8:03 am Post subject: |
|
|
Hi Keith,
I'm not able to recreate this one. What compiler version and OS are you using? Are you running 32 or 64-bits? Are there any other compile options?
Thanks,
Mat
| Code: | % cat chkptr.f90
module m
integer,save,pointer :: x,y
contains
subroutine init(x,y)
integer,pointer, intent(inout) :: x,y
nullify(x)
nullify(y)
end subroutine init
subroutine check_assoc
if( associated(x,y) ) then
write(*,*) "Yes"
else
write(*,*) "No"
end if
end subroutine check_assoc
end module m
program assoc_test
use m
nullify(x)
nullify(y)
call init(x,y)
call check_assoc
end program assoc_test
% pgf90 -C -Mchkptr chkptr.f90 -V12.9
% a.out
No
|
|
|
| Back to top |
|
 |
Keith Refson
Joined: 10 Jul 2006 Posts: 10
|
Posted: Wed Oct 10, 2012 9:43 am Post subject: |
|
|
Oops - I included the wrong code. This is the one which fails (with 12.9)
| Code: |
module m
type t
complex, pointer, dimension(:) :: p => null()
complex, allocatable, dimension(:) :: q
end type t
contains
subroutine init(x)
type(t), intent(inout) :: x
nullify(x%p)
end subroutine init
subroutine check_assoc(x)
type(t), intent(inout), target :: x
if( associated(x%p,x%q) ) then
write(*,*) "Yes"
else
write(*,*) "No"
end if
end subroutine check_assoc
end module m
program assoc_test
use m
type(t) :: x
call init(x)
call check_assoc(x)
end program assoc_test
|
|
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Fri Oct 12, 2012 1:31 pm Post subject: |
|
|
Thanks Keith. I sent this off to engineering and they agree that it's a compiler error. They will have a fix in place in as of the the 13.0 compilers.
- Mat |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|