This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Optimization + ANY + ALLOCATE
- From: C.Friedrich <c dot friedrich at fz-juelich dot de>
- To: <fortran at gcc dot gnu dot org>
- Date: Thu, 7 Jul 2016 10:45:44 +0200
- Subject: Optimization + ANY + ALLOCATE
- Authentication-results: sourceware.org; auth=none
Dear all,
there is a problem with optimization in gfortran 4.9.1 in the following
code:
----------
program test
implicit none
integer :: i,n
# ifdef BUG
integer, allocatable :: a(:)
allocate ( a(1) )
# else
integer :: a(1)
# endif
n = 1
a = 2
write(*,*) (any(a(i).eq.(/1,2,3/)) ,i=1,n)
write(*,*) (/ (any(a(i).eq.(/1,2,3/)) ,i=1,n) /)
write(*,*) any ( (/ (any(a(i).eq.(/1,2,3/)) ,i=1,n) /) )
end
-----------
The result should obviously read
T T T.
However, I also get the incorrect result
T F F:
gfortran -O0 -cpp test.f --> correct
gfortran -O1 -cpp test.f --> correct
gfortran -O2 -cpp test.f --> correct
gfortran -O3 -cpp test.f --> correct
gfortran -O0 -cpp -DBUG test.f --> correct
gfortran -O1 -cpp -DBUG test.f --> incorrect
gfortran -O2 -cpp -DBUG test.f --> incorrect
gfortran -O3 -cpp -DBUG test.f --> incorrect
So, there seems to be a problem with the combination
optimization+ANY+ALLOCATE.
Can you reproduce this problem?
Thank you!
Christoph
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr.-Ing. Wolfgang Marquardt (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------