Bug 16898 - Aliasing problem with array descriptors
Summary: Aliasing problem with array descriptors
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: 20538
  Show dependency treegraph
 
Reported: 2004-08-06 14:32 UTC by Paul Brook
Modified: 2005-06-04 21:01 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-03-11 15:23:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Brook 2004-08-06 14:32:50 UTC
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
Comment 1 Andrew Pinski 2004-08-07 22:09:14 UTC
Confirmed it is the aliasing sets which are incorrect.
Comment 2 Paul Thomas 2004-12-10 13:02:27 UTC
Andrew,

This one is fixed now, isn't it?  It runs fine with the CVS of 20041205
Comment 3 Paul Brook 2004-12-10 13:21:01 UTC
This is not fixed. 
It still fails for me at -O2 in i686-linux. 
Comment 4 Andreas Jaeger 2005-05-15 17:50:56 UTC
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.
Comment 5 Tobias Schlüter 2005-05-18 21:24:59 UTC
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.
Comment 6 GCC Commits 2005-06-04 21:00:00 UTC
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

Comment 7 Tobias Schlüter 2005-06-04 21:00:50 UTC
Fixed.
Comment 8 Tobias Schlüter 2005-06-04 21:01:11 UTC
The patch has been on mainline since May 18th.