https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68765
Bug ID: 68765
Summary: warning for aliasing restrict parameters
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
Consider this invalid example:
...
subroutine foo (a, b)
implicit none
integer :: a
integer :: b
a = 1
b = 0
a = a + 1
end subroutine
program main
implicit none
integer :: a
call foo(a, a)
if (a .ne. 1) call abort
end program main
...
The example is invalid because foo is called with aliasing parameters, while in
fortran, we assume that parameters do not alias by annotating them with
restrict, as demonstrated in the original dump:
...
foo (integer(kind=4) & restrict a, integer(kind=4) & restrict b)
{
*a = 1;
*b = 0;
*a = *a + 1;
}
...
foo (&a, &a);
...
...
When compiling with -Wall, we do not warn for this:
...
$ gfortran alias.f95 -fdump-tree-all -Wall
$
...
Marking this a fortran issue for now. [ Tough the same type of warning is
missing for c examples with explicit restrict ]