Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29283 Discussions

intent(inout) pointer can not be passed as intent(inout) pointer?

Grady_Schofield
Beginner
706 Views

The following code produces an error.

module

inout_inout

contains

subroutine

sub1( ptr )

integer, pointer, intent( inout ) :: ptr

nullify( ptr )

end subroutine

subroutine

sub2( ptr )

integer, pointer, intent( inout ) :: ptr

nullify( ptr )

call sub1( ptr ) !**** This is the line of the error

end subroutine

end module

The error is this:

Error1 Error: A pointer dummy argument with the INTENT(IN) attribute shall not appear as an actual argument if the associated dummy argument has the INTENT(OUT) or INTENT(INOUT) attribute. [PTR]S:srcdisk_io_testpointer_to_pointermod.f9022

I'm a little suspicious that there may be a compiler problem since the error message is saying sub2's pointer is intent(in) and not intent(inout), and I can't see why what I have here would be illegal.


0 Kudos
4 Replies
Steven_L_Intel1
Employee
706 Views
This is a compiler bug previously reported - it will be fixed in a future release.
0 Kudos
Grady_Schofield
Beginner
706 Views

Is there a public list of open compiler bugs? I am doing things with linked lists and a binary tree, and would like to know of any more pointer related gotcha's.

It seems that there is also a problem with modifying the contents of an object pointed to by an intent(in) pointer.

module

pointer_pointer

type

data_struct

integer :: int_data

integer, pointer :: int_ptr

end

type

contains

subroutine

sub1( ptr )

implicit none

type( data_struct ), pointer, intent( in ) :: ptr

type( data_struct ), pointer :: null_ptr => null( )

integer, target :: x

ptr => null_ptr !**** This should cause an error

ptr%int_data = x !**** This should not

ptr%int_ptr => x !**** This should not

end subroutine

subroutine

sub2( ptr )

implicit none

type( data_struct ), pointer, intent( in ) :: ptr

type( data_struct ), pointer :: tmp_ptr

integer, target :: x

tmp_ptr => ptr

tmp_ptr%int_data = x

tmp_ptr%int_ptr => x

end subroutine

end module

There are no errors in sub2, and this is the work-around I have for this problem. But the three commented lines in sub1 all

produce errors. I'm a little suspicious since the third line produces the same error as the first line. It seems the compiler

doesn't understand what is going on. These are the errors.

Error1 Error: A pointer dummy argument with the INTENT(IN) attribute shall not appear as an pointer-object in a pointer-assignment-stmt or nullify-stmt. [PTR]S:srcdisk_io_testpointer_to_pointersubr.f9022
Error2 Error: A dummy argument with the INTENT(IN) attribute shall not appear in a variable definition context [PTR]S:srcdisk_io_testpointer_to_pointersubr.f9023
Error3 Error: A pointer dummy argument with the INTENT(IN) attribute shall not appear as an pointer-object in a pointer-assignment-stmt or nullify-stmt. [PTR]S:srcdisk_io_testpointer_to_pointersubr.f9024

0 Kudos
Steven_L_Intel1
Employee
706 Views
There is no public list. Most known errors would be very difficult to describe in a meaningful fashion.

I will need to study your new example - I'll get back to you on Monday. At first glance, Error 1 seems correct but I agree that the other two may not be.
0 Kudos
Steven_L_Intel1
Employee
706 Views
I agree with the comments in your code - the first assignment should be an error (and is reported as one.) The second and third should be allowed but aren't. I'll report this to the developers. Thanks for bringing it to our attention.
0 Kudos
Reply