Following code compiled with gfortran -O2 -mtune=i686 Could be a frontend bug not setting alias sets properly. When foo is inlined, a=>NULL is then scheduled after the body of foo. Based on gfortran.dg/ret_pointer_1.f90 program aliasing_borken integer, pointer, dimension(:) :: a integer, target, dimension(2) :: b a => NULL() call foo(a); if (.not. associated (a, b)) call abort contains subroutine foo(r) integer, pointer, dimension(:) :: r r => b end subroutine end program
Confirmed it is the aliasing sets which are incorrect.
Andrew, This one is fixed now, isn't it? It runs fine with the CVS of 20041205
This is not fixed. It still fails for me at -O2 in i686-linux.
I have on Linux/x86-64 these passes - which means all of them pass: XPASS: gfortran.dg/ret_pointer_1.f90 -O0 execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O1 execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O2 execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O3 -fomit-frame-pointer execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O3 -fomit-frame-pointer -funroll-loops e xecution test XPASS: gfortran.dg/ret_pointer_1.f90 -O3 -fomit-frame-pointer -funroll-all-loop s -finline-functions execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O3 -g execution test XPASS: gfortran.dg/ret_pointer_1.f90 -Os execution test On Linux/i686 I get less passes: XPASS: gfortran.dg/ret_pointer_1.f90 -O0 execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O1 execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O3 -fomit-frame-pointer execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O3 -fomit-frame-pointer -funroll-loops execution test XPASS: gfortran.dg/ret_pointer_1.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test So, -Os and -O2 are broken on i686.
Fixed by Zdenek's recent patch: http://gcc.gnu.org/ml/fortran/2005-05/msg00178.html, keeping this bug open until the patch is also committed to the 4.0 branch.
Subject: Bug 16898 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: tobi@gcc.gnu.org 2005-06-04 20:59:51 Modified files: gcc/fortran : ChangeLog trans-types.c gcc/testsuite : ChangeLog gcc/testsuite/gfortran.dg: ret_pointer_1.f90 Log message: fortran/ 2005-06-04 Zdenek Dvorak <dvorakz@suse.cz> PR fortran/16898 * trans-types.c (gfc_array_range_type): New variable. (gfc_init_types): Initialize gfc_array_range_type. (gfc_get_array_type_bounds): Use gfc_array_range_type. testsuite/ 2005-06-04 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de> PR fortran/16898 * gfortran.dg/ret_pointer_1.f90: Un-XFAIL. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.64&r2=1.335.2.65 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-types.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.37.10.5&r2=1.37.10.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.226&r2=1.5084.2.227 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/ret_pointer_1.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1&r2=1.1.48.1
Fixed.
The patch has been on mainline since May 18th.