[Bug fortran/81048] New: incorrect derived type initialization
dm577216smith at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Jun 10 08:09:00 GMT 2017
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
dsmith@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
More information about the Gcc-bugs
mailing list