https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107501
Bug ID: 107501 Summary: Aliasing warning not working properly in certain situations Product: gcc Version: og11 (devel/omp/gcc-11) Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mhbalsmeier at mail dot de Target Milestone: --- Created attachment 53816 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53816&action=edit source file Hi, this is my first bug report. During developing a scientific code I found that the -Waliasing warning is not thrown in certain situations where in fact it should be thrown. The following code shows three calls to a subroutine, but in one of them, the alaising warning does not appear. program test implicit none type t_state real(8) :: array_1(2,2) real(8) :: array_2(2,2) real(8) :: array_3(2,2) end type t_state type(t_state) :: state real(8) :: array_1(2,2) real(8) :: array_2(2,2) real(8) :: array_3(2,2) state%array_1 = .0 state%array_2 = .0 state%array_3 = .0 array_1 = .0 array_2 = .0 array_3 = .0 ! should trigger warning, but doesn't call aliasing_routine_1(state%array_1,state%array_2,state%array_3,state%array_2,state%array_3) ! does trigger warning, as it should call aliasing_routine_1(array_1,array_2,array_3,array_2,array_3) ! does trigger warning, as it should call aliasing_routine_2(state%array_1,state%array_2,state%array_2) contains subroutine aliasing_routine_1(factor,in_1,in_2,out_1,out_2) real(8), intent(in) :: factor(:,:) real(8), intent(in) :: in_1(:,:) real(8), intent(in) :: in_2(:,:) real(8), intent(out) :: out_1(:,:) real(8), intent(out) :: out_2(:,:) out_1 = factor*in_1 out_2 = factor*in_2 end subroutine aliasing_routine_1 subroutine aliasing_routine_2(factor,in_1,out_1) real(8), intent(in) :: factor(:,:) real(8), intent(in) :: in_1(:,:) real(8), intent(out) :: out_1(:,:) out_1 = factor*in_1 end subroutine aliasing_routine_2 end program test