[Bug fortran/81048] New: incorrect derived type initialization

2017-06-09 Thread dm577216smith at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81048

Bug ID: 81048
   Summary: incorrect derived type initialization
   Product: gcc
   Version: 6.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dm577216smith at gmail dot com
  Target Milestone: ---

A large program that ran correctly on several previous versions of gfortran
(and other compilers) failed when I installed from gfortran-6.3-Sierra.dmg
and CommandLineToolsforXcode8.3.2.dmg on a new Mac.

Please let me know if this is a gfortran6 bug, or if I have messed up the
installation.

Thanks,

David Smith
dsm...@lmu.edu


---

I will include a small program that seems to show the problem.

I think this is the correct output, from gfortran 5:

~ $ gfortran gfortran6test.f95 -o gfortran6test
~ $ gfortran6test
  a%f =   -1
  b(1:3)%f =-1  -1  -1
  g2(1:3)%f =   -1  -1  -1
  b = g(a) gives b(1:3)%f =   -2  -2   
  -2
  h2(1:3)%f =   -1  -1  -1
  b = h(a) gives b(1:3)%f =   -2  -2   
  -2
~ $ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.2.0/lto-wrapper
Target: x86_64-apple-darwin14
Configured with: ../gcc-5.2.0/configure --prefix=/usr/local/gfortran
--with-gmp=/Users/fx/devel/gcc/deps-static/x86_64 
--enable-languages=c,c++,fortran,objc,obj-c++ --build=x86_64-apple-darwin14
Thread model: posix
gcc version 5.2.0 (GCC) 


---


Here is my output from 6.3:

~ $ gfortran gfortran6test.f95 -o gfortran6test
~ $ gfortran6test
  a%f =   -1
  b(1:3)%f =-1  -1  -1
  g2(1:3)%f =   -1  -1  -1
  b = g(a) gives b(1:3)%f =   -2  -2   
  -2
  h2(1:3)%f =   -2  -2  -2
  b = h(a) gives b(1:3)%f =   -12346  -12346 
-12346
~ $ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin16/6.3.0/lto-wrapper
Target: x86_64-apple-darwin16
Configured with: ../gcc-6.3.0/configure --prefix=/usr/local/gfortran
--enable-languages=c,c++,
fortran,objc,obj-c++ --build=x86_64-apple-darwin16
--with-gmp=/Users/fx/devel/gcc/deps-static/x86_64
 --with-mpfr=/Users/fx/devel/gcc/deps-static/x86_64
--with-mpc=/Users/fx/devel/gcc/deps-static/x86_64
 --with-isl=/Users/fx/devel/gcc/deps-static/x86_64
Thread model: posix
gcc version 6.3.0 (GCC) 
~ $ 

---


module m
   type f
   integer :: f = -1
   end type
   interface g
   module procedure g2
   end interface
   contains
   function g2(a)
  type(f) :: a, g2(3)
  write (*,*) ' g2(1:3)%f = ', g2(1:3)%f
  do j = 1, 3
 if (g2(j)%f == -1) then
 g2(j)%f = a%f - 1
 else
 g2(j)%f = a%f - 12345
 endif
  enddo
   end function g2
end module m

module m2
   use m
   interface h
   module procedure h2
   end interface
   contains
   function h2(a)
  type(f) :: a, h2(3)
  write (*,*) ' h2(1:3)%f = ', h2(1:3)%f
  do j = 1, 3
 if (h2(j)%f == -1) then
 h2(j)%f = a%f - 1
 else
 h2(j)%f = a%f - 12345
 endif
  enddo
   end function h2
end module m2

program test
   use m2
   type(f) :: a, b(3)
   write (*,*) ' a%f = ', a%f
   write (*,*) ' b(1:3)%f =  ', b(1:3)%f
   b = g(a)
   write (*,*) ' b = g(a) gives b(1:3)%f = ', b(1:3)%f
   b = h(a)
   write (*,*) ' b = h(a) gives b(1:3)%f = ', b(1:3)%f
end program test

[Bug fortran/66864] New: floor function error

2015-07-13 Thread dm577216smith at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66864

Bug ID: 66864
   Summary: floor function error
   Product: gcc
   Version: 5.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dm577216smith at gmail dot com
  Target Milestone: ---

Here is a small program showing an error in the FLOOR function on my machine.
I get similar results with gfortran 5.1 and also an older 4.6 version.

I noticed that each of the incorrect results, 94906264, 777666496, and
200004
seem to be the correct value chopped to 24 bits.

Also, if I compile the program with 64-bit integers with -fdefault-integer-8,
all the results are ok.


  PROGRAM T

  DOUBLE PRECISION :: X

  WRITE (*,*) ' '

  X = 2.0D0 ** 26.5D0
  WRITE (*,*) ' X = 2.0D0 ** 26.5D0 = ', X
  WRITE (*,*) ' FLOOR(X) = ', FLOOR(X)
  WRITE (*,*) ' '

  WRITE (*,*) ' But  FLOOR( 2.0D0 ** 26.5D0 ) = ', FLOOR( 2.0D0 ** 26.5D0 )
  WRITE (*,*) ' '
  WRITE (*,*) ' '

  X = 777666555.6D0
  WRITE (*,*) ' X = 777666555.6D0 gives ', X,'  FLOOR(X) = ', FLOOR(X)
  WRITE (*,*) ' '

  WRITE (*,*) ' But  FLOOR(777666555.6D0) = ', FLOOR(777666555.6D0)
  WRITE (*,*) ' '
  WRITE (*,*) ' '

  X = 2000111222.6D0
  WRITE (*,*) ' X = 2000111222.6D0 gives ', X,'  FLOOR(X) = ', FLOOR(X)
  WRITE (*,*) ' '

  WRITE (*,*) ' But  FLOOR(2000111222.6D0) = ', FLOOR(2000111222.6D0)
  WRITE (*,*) ' '
  WRITE (*,*) ' '

  END PROGRAM T


Output from the program:


  X = 2.0D0 ** 26.5D0 =94906265.624251559 
  FLOOR(X) = 94906265

  But  FLOOR( 2.0D0 ** 26.5D0 ) = 94906264


  X = 777666555.6D0 gives777666555.6002FLOOR(X) =777666555

  But  FLOOR(777666555.6D0) =777666496


  X = 2000111222.6D0 gives2000111222.599FLOOR(X) =   2000111222

  But  FLOOR(2000111222.6D0) =   200004