[Bug fortran/82065] gfortran rejects redundant use of intrinsic module constant

2018-10-28 Thread c.friedr...@fz-juelich.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82065

c.friedr...@fz-juelich.de changed:

   What|Removed |Added

 CC||c.friedr...@fz-juelich.de

--- Comment #6 from c.friedr...@fz-juelich.de ---
Slightly different case but probably the same bug:

  subroutine sub(i)
c  if(i==1.or.i==2) call sub1 ! this works
  if(any(i==[1,2])) call sub1 ! this does not
  call sub2 

  contains  

  subroutine sub1   
  use iso_fortran_env   
  real(real64) :: a 
  end subroutine sub1   

  subroutine sub2   
  use iso_fortran_env   
  real(real64) :: b 
  end subroutine sub2

  end

Compilation fails with any optimization level different from -O0:
/tmp/ccZ13RIp.s: Assembler messages:
/tmp/ccZ13RIp.s:23: Error: symbol `__iso_fortran_env_MOD_real64' is already
defined

Slight changes of the code makes the error disappear. For example, not using
the "any" construction in the if command. Or commenting out one of the two
subroutine calls. Or commening out any of the declarations (a or b) in the
subroutines. Or using "real(8)" instead of "real(real64)".

Tested versions: 5.5.0, 7.3.0

[Bug fortran/71795] New: Two Bugs in array constructors (optimization)

2016-07-07 Thread c.friedr...@fz-juelich.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71795

Bug ID: 71795
   Summary: Two Bugs in array constructors (optimization)
   Product: gcc
   Version: 4.9.1
Status: UNCONFIRMED
  Severity: critical
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: c.friedr...@fz-juelich.de
  Target Milestone: ---

1st bug: 

There is a problem with array constructors and 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


2nd bug:

A similar problem appears in

--

  program test

  implicit none
  integer :: i,j,n

  real(8) :: arr(1,1,3)
  real(8) :: d(3)

  arr = 1d0
  n   = 1
  d   = (/ ( sum ( (/ (arr(j,j,i), j=1,1) /) ) , i=1,3 ) /) / n  !!!

  write(*,*) d

  end

--

It runs correctly without optimization, but with optimization (all levels) it
gives
Infinity Infinity Infinity

Without "/ n" at "!!!" it runs correctly with optimizations, too.


Thank you!

Christoph

---

BTW, this is the output of "gcc -v":

Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --disable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-51)