Optimization + ANY + ALLOCATE

Andre Vehreschild vehre@gmx.de
Thu Jul 7 11:19:00 GMT 2016


Hi Christoph,

Confirmed for trunk. The issue is present in trunk, too. Please file a
bugreport.

- Andre

On Thu, 7 Jul 2016 10:45:44 +0200
C.Friedrich <c.friedrich@fz-juelich.de> wrote:

> 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
> ------------------------------------------------------------------------------------------------
> ------------------------------------------------------------------------------------------------
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 



More information about the Fortran mailing list