[Bug fortran/95718] New: Wrong pointer associated status without initialization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95718 Bug ID: 95718 Summary: Wrong pointer associated status without initialization Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: peng.w...@compiler-dev.com Target Milestone: --- consider the code below: program test integer,pointer::ptr integer,pointer::ptr1 integer,pointer::ptr2 integer,pointer::ptr3 integer,pointer::ptr4 print*,associated(ptr),'associated(ptr)' print*,associated(ptr1),'associated(ptr1)' print*,associated(ptr2),'associated(ptr2)' print*,associated(ptr3),'associated(ptr3)' print*,associated(ptr4),'associated(ptr4)' end program test #gfortran -std=f2008 test.f90 ; ./a.out T associated(ptr) F associated(ptr1) T associated(ptr2) F associated(ptr3) T associated(ptr4) the associated status of the pointers is uncertain after the execution above. according to F2008 draft 16.5.2.7, the associated status of the pointer should be F in the case above. this is the options given when GCC was configured: # gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/local/gcc/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/usr/local/gcc -enable-checking=release -enable-languages=c,fortran -disable-bootstrap -disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.1.0 (GCC)
[Bug fortran/95718] [8/9/10/11 Regression] Wrong pointer associated status without initialization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95718 --- Comment #4 from PengWang --- (In reply to kargl from comment #3) >16.5.2.2 Pointer association status > >A pointer may have a pointer association status of associated, >disassociated, or undefined. Its association status may change >during execution of a program. Unless a pointer is initialized >(explicitly or by default), it has an initial association status >of undefined. A pointer may be initialized to have an association >status of disassociated or associated. > >13.7.16 ASSOCIATED (POINTER [, TARGET]) > >POINTER shall be a pointer. It may be of any type or may be a > procedure pointer. Its pointer association status shall not > be undefined. > > Your program is invalid. thank you very much! The status of undefined has confused me for a long time, now I understand it finally, thank you~
[Bug fortran/96294] New: Compile error for pointer function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96294 Bug ID: 96294 Summary: Compile error for pointer function Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: peng.w...@compiler-dev.com Target Milestone: --- I got a testcase like this: program a IMPLICIT NONE myfunc() = 311 print*,myfunc() contains FUNCTION myfunc() RESULT (result_ptr) IMPLICIT NONE INTEGER, POINTER :: result_ptr INTEGER, SAVE, TARGET:: targ result_ptr => targ END FUNCTION myfunc end program a But I got a compile error for the testcase above: func-04.f90:7:4: 7 | FUNCTION myfunc() RESULT (result_ptr) |1 Error: INTERNAL-PROC procedure at (1) is already declared as STATEMENT-PROC procedure. F2008: A pointer function assignment is ambiguous if it is the first executable statement after the specification block. Please add any other kind of executable statement before it. FIXME func-04.f90:7:4: 7 | FUNCTION myfunc() RESULT (result_ptr) |1 Error: Statement function ‘myfunc’ at (1) may not have pointer or allocatable attribute func-04.f90:3:19: 3 | myfunc() = 311 | 1 Error: Pointer assignment target cannot be a constant at (1) I wonder if this pointer function feature is not support by gfortran ,or if it is a bug above? this is the options given when GCC was configured: # gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/local/gcc/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/usr/local/gcc -enable-checking=release -enable-languages=c,fortran -disable-bootstrap -disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.1.0 (GCC)
[Bug fortran/96294] Compile error for pointer function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96294 --- Comment #2 from PengWang --- (In reply to Dominique d'Humieres from comment #1) > read > > F2008: A pointer function assignment is ambiguous if it is the first > executable statement after the specification block. Please add any other > kind of executable statement before it. FIXME > > program a > IMPLICIT NONE > print *, "begin" > myfunc() = 311 > print*,myfunc() > > contains > FUNCTION myfunc() RESULT (result_ptr) > IMPLICIT NONE > INTEGER, POINTER :: result_ptr > INTEGER, SAVE, TARGET:: targ > > result_ptr => targ > END FUNCTION myfunc > end program a > > gives > > begin > 311 Where is this explanation to be found, I have not seen it yet, maybe the standard documents that I have are imcomplete, Can I have the download link of your standard document? thank you very much!!!
[Bug fortran/96294] Compile error for pointer function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96294 --- Comment #4 from PengWang --- (In reply to Dominique d'Humieres from comment #3) > See https://gcc.gnu.org/wiki/GFortranStandards. thanks a lot!!! ^_^