Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
6 Views

compiler bug with /check:bounds and derived type

The program below compiles and runs with gfortran and g95 and also with ifort without the /check:bounds option, giving output 42.0. It also runs if components other than ff of the derived type are removed.

c:\fortran\ifort\sge>ver

Microsoft Windows [Version 10.0.16299.371]

c:\fortran\ifort\sge>type xbug.f90 
program xbar
implicit none
integer, parameter :: dp = kind(1.0d0)
type :: foo
   integer       :: n
   real(kind=dp) :: ff,gg,hh
   real(kind=dp), allocatable :: cc(:),dd(:),ee(:)
end type
integer, parameter :: nx=2
type(foo), allocatable :: xx(:)
allocate (xx(nx))
xx = bar(["a","b"])
xx(1)%ff = 42.0_dp
print*,xx(1)%ff
contains
function bar(ss) result(yy)
character (len=*), intent(in)  :: ss(:)
type(foo)                      :: yy(size(ss))
end function bar
end program xbar

c:\fortran\ifort\sge>ifort /traceback /check:bounds xbug.f90 
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.0.045 Beta Build 20180317
Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

ifort: NOTE: The Beta evaluation period for this product ends on 11-oct-2018 UTC.
xbug.f90(16): warning #6178: The return value of this FUNCTION has not been defined.   [YY]
function bar(ss) result(yy)
------------------------^
Microsoft (R) Incremental Linker Version 14.00.24234.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:xbug.exe 
-subsystem:console 
-incremental:no 
xbug.obj 

c:\fortran\ifort\sge>xbug.exe
forrtl: severe (157): Program Exception - access violation
Image              PC                Routine            Line        Source             
xbug.exe           00007FF6B4085F21  Unknown               Unknown  Unknown
xbug.exe           00007FF6B4086447  Unknown               Unknown  Unknown
xbug.exe           00007FF6B4081526  MAIN__                     12  xbug.f90
xbug.exe           00007FF6B40D6E22  Unknown               Unknown  Unknown
xbug.exe           00007FF6B40D71C5  Unknown               Unknown  Unknown
KERNEL32.DLL       00007FFA2B501FE4  Unknown               Unknown  Unknown
ntdll.dll          00007FFA2BCBF061  Unknown               Unknown  Unknown

0 Kudos
4 Replies
Valued Contributor III
6 Views

But the value of you is not

But the value of yy is not defined in the function??
0 Kudos
Highlighted
Beginner
6 Views

Quote:andrew_4619 wrote:

andrew_4619 wrote:

But the value of yy is not defined in the function??

When I set the function result the problem remains:

c:\fortran\ifort\sge>type xbug.f90 
program xbar
implicit none
integer, parameter :: dp = kind(1.0d0)
type :: foo
   integer       :: n
   real(kind=dp) :: ff,gg,hh
   real(kind=dp), allocatable :: cc(:),dd(:),ee(:)
end type
integer, parameter :: nx=2
type(foo), allocatable :: xx(:)
allocate (xx(nx))
xx = bar(["a","b"])
xx(1)%ff = 42.0_dp
print*,xx(1)%ff
contains
function bar(ss) result(yy)
character (len=*), intent(in)  :: ss(:)
type(foo)                      :: yy(size(ss))
integer                        :: i
do i=1,size(ss)
   yy(i)%n = 0
   yy(i)%ff = 0.0_dp
   yy(i)%gg = 0.0_dp
   yy(i)%hh = 0.0_dp
   allocate(yy(i)%cc(1),yy(i)%dd(1),yy(i)%ee(1))
   yy(i)%cc = 0.0_dp
   yy(i)%dd = 0.0_dp
   yy(i)%ee = 0.0_dp
end do
end function bar
end program xbar

c:\fortran\ifort\sge>ifort /traceback /check:bounds xbug.f90 
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.0.045 Beta Build 20180317
Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

ifort: NOTE: The Beta evaluation period for this product ends on 11-oct-2018 UTC.
Microsoft (R) Incremental Linker Version 14.00.24234.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:xbug.exe 
-subsystem:console 
-incremental:no 
xbug.obj 

c:\fortran\ifort\sge>xbug.exe
forrtl: severe (157): Program Exception - access violation
Image              PC                Routine            Line        Source             
xbug.exe           00007FF66F43A5A1  Unknown               Unknown  Unknown
xbug.exe           00007FF66F43AAC7  Unknown               Unknown  Unknown
xbug.exe           00007FF66F431CAB  MAIN__                     12  xbug.f90
xbug.exe           00007FF66F4876E2  Unknown               Unknown  Unknown
xbug.exe           00007FF66F487A85  Unknown               Unknown  Unknown
KERNEL32.DLL       00007FFA2B501FE4  Unknown               Unknown  Unknown
ntdll.dll          00007FFA2BCBF061  Unknown               Unknown  Unknown

0 Kudos
Highlighted
Valued Contributor III
6 Views

@Vivek R.,

@Vivek R.,

it looks a bug in Intel Fortran with the problem existing in the current official release of compiler 18.0 Update 2 as well.

I suggest you submit this at Intel support:

https://supporttickets.intel.com/?lang=en-US

0 Kudos
Highlighted
Beginner
6 Views

Quote:FortranFan wrote:

FortranFan wrote:

@Vivek R.,

it looks a bug in Intel Fortran with the problem existing in the current official release of compiler 18.0 Update 2 as well.

I suggest you submit this at Intel support:

https://supporttickets.intel.com/?lang=en-US

Done. Thanks for confirming that it is a bug.

0 Kudos