├── LICENSE ├── README.md ├── classic-flang-bugs ├── CMakeLists.txt ├── flang-20170611a.f90 ├── flang-20170611b.f90 ├── flang-20170611c.f90 ├── flang-20170923a.f90 ├── flang-20170923b.f90 ├── flang-20170923c.f90 ├── flang-20170924a.f90 ├── flang-20170924b.f90 ├── flang-20170924c.f90 ├── flang-20170930a.f90 ├── flang-20170930b.f90 ├── flang-20170930c.f90 ├── flang-20171122a.f90 ├── flang-20171122b.f90 ├── flang-20171122c.f90 ├── flang-20171122d.f90 ├── flang-20171122e.f90 ├── flang-20171122f.f90 ├── flang-20171122g.f90 ├── flang-20171122h.f90 ├── flang-20171123a.f90 ├── flang-20171123b.f90 ├── flang-20180120.f90 ├── flang-20180319a.f90 ├── flang-20180319b.f90 ├── flang-20190503a.f90 ├── flang-20190503b.f90 ├── flang-20190504a.f90 ├── flang-20190504b.f90 ├── flang-20190504c.f90 ├── flang-20190505a.f90 ├── flang-20190506b.f90 ├── flang-20190506c.f90 ├── flang-20190511a.f90 ├── flang-20190511b.f90 ├── flang-20190511c.f90 ├── flang-20190512a.f90 ├── log-20180921.txt ├── log-20181226.txt └── log-20190329.txt ├── cmake └── testing.cmake ├── flang-bugs ├── CMakeLists.txt ├── flang-20250504.F90 └── mpi_bcast.f90 ├── gfortran-bugs ├── CMakeLists.txt ├── char-par-inquiry.f90 ├── gfortran-20100924.f90 ├── gfortran-20100925.f90 ├── gfortran-20110528.f90 ├── gfortran-20110616.f90 ├── gfortran-20120411.f90 ├── gfortran-20150912a.f90 ├── gfortran-20150913.f90 ├── gfortran-20151101.f90 ├── gfortran-20151102a.f90 ├── gfortran-20151102b.f90 ├── gfortran-20151108.f90 ├── gfortran-20160129.f90 ├── gfortran-20160319a.f90 ├── gfortran-20160319b.f90 ├── gfortran-20160320.f90 ├── gfortran-20160321.f90 ├── gfortran-20160821.f90 ├── gfortran-20170112a.f90 ├── gfortran-20170112b.f90 ├── gfortran-20170812a.f90 ├── gfortran-20170812b.f90 ├── gfortran-20171114a.f90 ├── gfortran-20171114b.f90 ├── gfortran-20171114c.f90 ├── gfortran-20171115.f90 ├── gfortran-20171122.f90 ├── gfortran-20171122b.f90 ├── gfortran-20171124a.f90 ├── gfortran-20171124b.f90 ├── gfortran-20171124c.f90 ├── gfortran-20171124d.f90 ├── gfortran-20171124e-main.f90 ├── gfortran-20171124e.f90 ├── gfortran-20171124f-main.f90 ├── gfortran-20171124f.f90 ├── gfortran-20180128.f90 ├── gfortran-20180129.f90 ├── gfortran-20180130a.f90 ├── gfortran-20180130b.f90 ├── gfortran-20180130c.f90 ├── gfortran-20180130d.f90 ├── gfortran-20180130e.f90 ├── gfortran-20180223a.f90 ├── gfortran-20180223b.f90 ├── gfortran-20180224.f90 ├── gfortran-20180610.f90 ├── gfortran-20181114-main.f90 ├── gfortran-20181114.f90 ├── gfortran-20190202.f90 ├── gfortran-20200402-file1.f90 ├── gfortran-20200402-file2.f90 ├── gfortran-20200501.f90 ├── gfortran-20201204.f90 ├── gfortran-20210527.f90 ├── gfortran-20211123.f90 ├── gfortran-20220127.f90 ├── gfortran-20220128.f90 ├── gfortran-20220221-main.f90 ├── gfortran-20220221-module.f90 ├── gfortran-20220221-submodule.f90 ├── gfortran-20230513.f90 ├── gfortran-20230527.f90 ├── gfortran-20230529.f90 ├── gfortran-20230612.f90 ├── gfortran-20231211.f90 ├── gfortran-20240425.f90 ├── gfortran-20241125.f90 ├── gfortran-20250401.f90 ├── gfortran-20250428.f90 ├── gfortran-20250605.f90 ├── gfortran-bug-20110528.f90 ├── log-10.2.0.txt ├── log-11.1.0.txt ├── log-11.2.0.txt ├── log-11.3.0.txt ├── log-11.4.0.txt ├── log-12.1.0.txt ├── log-12.2.0.txt ├── log-12.3.0.txt ├── log-12.4.0.txt ├── log-13.1.0.txt ├── log-13.2.0.txt ├── log-13.3.0.txt ├── log-14.1.0.txt ├── log-14.2.0.txt ├── log-15.1.0.txt └── log-9.3.0.txt ├── ibm-bugs ├── CMakeLists.txt ├── ibm-20180301a.f90 ├── ibm-20180301b.f90 ├── ibm-20180301c.F90 ├── ibm-20180306a.f90 ├── ibm-20180306b.f90 ├── ibm-20180703.f90 ├── ibm-20181201.f90 ├── ibm-20181203a.f90 ├── ibm-20181203b.f90 ├── ibm-20181203c.f90 └── ibm-20181203d.f90 ├── intel-bugs ├── CMakeLists.txt ├── intel-20121001.f90 ├── intel-20121006.f90 ├── intel-20121006a.f90 ├── intel-20121006b-main.f90 ├── intel-20121006b.f90 ├── intel-20121007a.f90 ├── intel-20121007b.f90 ├── intel-20121008.f90 ├── intel-20121013.f90 ├── intel-20121013a.f90 ├── intel-20121014.f90 ├── intel-20130330.F90 ├── intel-20130802.f90 ├── intel-20130802a.f90 ├── intel-20131030.f90 ├── intel-20140109.f90 ├── intel-20140420.f90 ├── intel-20140424.f90 ├── intel-20140609.f90 ├── intel-20140610.f90 ├── intel-20140616.f90 ├── intel-20140617.f90 ├── intel-20140618a.f90 ├── intel-20140618b.f90 ├── intel-20141014-main.f90 ├── intel-20141014.f90 ├── intel-20150531.f90 ├── intel-20150601.f90 ├── intel-20171018.f90 ├── intel-20171019.f90 ├── intel-20171019a.f90 ├── intel-20171023.f90 ├── intel-20171115.f90 ├── intel-20171126.f90 ├── intel-20180115.f90 ├── intel-20180117.f90 ├── intel-20180221.f90 ├── intel-20180222.f90 ├── intel-20190901.f90 ├── intel-20190903.f90 ├── intel-20190903b.f90 ├── intel-20190909.f90 ├── intel-20191228.f90 ├── intel-20191229.f90 ├── intel-20200125.f90 ├── intel-20200213.f90 ├── intel-20200715.tar.gz ├── intel-20200721.f90 ├── intel-20210619.f90 ├── intel-20211122.f90 ├── intel-20220211.f90 ├── intel-20230603.f90 ├── intel-20230604.f90 ├── intel-20231122.f90 ├── intel-20231123.f90 ├── intel-20231205.f90 ├── intel-20231210.f90 ├── intel-20231213.f90 ├── intel-20240327.f90 ├── intel-20241010.f90 ├── intel-20241231.f90 ├── intel-20250428.f90 ├── intel-20250605.f90 ├── log-17.0.8.txt ├── log-18.0.6.txt ├── log-19.0.5.txt ├── log-19.1.0.txt ├── log-2024.0.txt ├── log-2024.1.txt ├── log-2024.2.txt ├── log-2025.0.txt ├── log-2025.1.txt ├── log-21.10.0.txt ├── log-21.11.0.txt ├── log-21.11.1.txt ├── log-21.12.0.txt └── log-21.9.0.txt ├── nag-bugs ├── CMakeLists.txt ├── log-6.0.1071.txt ├── log-6151.txt ├── log-6252.txt ├── log-6254.txt ├── log-7008.txt ├── log-7125.txt ├── log-7130.txt ├── log-7141.txt ├── log-7142.txt ├── log-7143.txt ├── log-7144.txt ├── log-7200.txt ├── log-7220.txt ├── log-7221.txt ├── log-7225.txt ├── nag-20121007.f90 ├── nag-20121111.f90 ├── nag-20130818.f90 ├── nag-20131204.f90 ├── nag-20140108.f90 ├── nag-20140417.f90 ├── nag-20140616.f90 ├── nag-20140617.f90 ├── nag-20150321.f90 ├── nag-20150520.f90 ├── nag-20150528-main.f90 ├── nag-20150528.f90 ├── nag-20160129-main.f90 ├── nag-20160129.f90 ├── nag-20160321.f90 ├── nag-20170805a.f90 ├── nag-20170805b.f90 ├── nag-20171027.f90 ├── nag-20171110.f90 ├── nag-20180127a.f90 ├── nag-20180201.f90 ├── nag-20180202a.f90 ├── nag-20180202b.f90 ├── nag-20180202c.f90 ├── nag-20180203a.f90 ├── nag-20180203b.f90 ├── nag-20180203c.f90 ├── nag-20180203e.f90 ├── nag-20180203f.f90 ├── nag-20180204a.f90 ├── nag-20180204b.f90 ├── nag-20180204c.f90 ├── nag-20180204d.f90 ├── nag-20180204e.f90 ├── nag-20180205a.f90 ├── nag-20180205b.f90 ├── nag-20180205c.f90 ├── nag-20180219.f90 ├── nag-20180323.f90 ├── nag-20180731.f90 ├── nag-20180819.f90 ├── nag-20190302.f90 ├── nag-20190506.f90 ├── nag-20190507.f90 ├── nag-20190608.f90 ├── nag-20190826a.f90 ├── nag-20190826b.f90 ├── nag-20190831.f90 ├── nag-20190906.f90 ├── nag-20200110.f90 ├── nag-20200124.f90 ├── nag-20200213.f90 ├── nag-20220103.f90 ├── nag-20220104.f90 ├── nag-20220117.f90 ├── nag-20220127.f90 ├── nag-20220312.f90 ├── nag-20220421.f90 ├── nag-20230426.f90 ├── nag-20230426b.f90 ├── nag-20230527.f90 ├── nag-20230529.f90 ├── nag-20230603a.f90 ├── nag-20230603b.f90 ├── nag-20230603c.f90 ├── nag-20231204.f90 ├── nag-20231206.f90 ├── nag-20231211.f90 ├── nag-20231213.f90 ├── nag-20241130.f90 └── nag-20250124.f90 └── pgi-bugs ├── CMakeLists.txt ├── pgi-20180320.f90 ├── pgi-20180505a.f90 ├── pgi-20180505b.f90 ├── pgi-20180505c.f90 ├── pgi-bitfun-kind.f90 ├── pgi-constructor-1.f90 ├── pgi-dflt-init-1.f90 ├── pgi-dflt-init-2.f90 ├── pgi-dt-asn-1.f90 ├── pgi-ptr-rank-remap-1.f90 ├── pgi-ptr-rank-remap-2.f90 ├── pgi-src-alloc-2.f90 └── pgi-src-alloc-3.f90 /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2018 Neil N. Carlson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170611a.f90: -------------------------------------------------------------------------------- 1 | ! https://github.com/flang-compiler/flang/issues/96 2 | ! Fixed as of 9/22/2017 3 | 4 | subroutine get_buffer(cptr, buflen, buffer) 5 | use,intrinsic :: iso_c_binding, only: c_char, c_size_t, c_ptr, c_f_pointer 6 | type(c_ptr), intent(in) :: cptr 7 | integer(c_size_t), intent(in) :: buflen 8 | character(:,kind=c_char), pointer, intent(out) :: buffer 9 | buffer => f_string_pointer(cptr, buflen) 10 | contains 11 | function f_string_pointer(cptr, len) result(fptr) 12 | type(c_ptr), intent(in) :: cptr 13 | integer(c_size_t), intent(in) :: len 14 | character(len,kind=c_char), pointer :: fptr 15 | call c_f_pointer(cptr, fptr) 16 | end function 17 | end subroutine get_buffer 18 | 19 | 20 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170611b.f90: -------------------------------------------------------------------------------- 1 | ! https://github.com/flang-compiler/flang/issues/96 2 | ! Fixed as of 9/22/2017 3 | 4 | module example 5 | type any_vector 6 | class(*), allocatable :: val(:) 7 | contains 8 | procedure :: get 9 | end type 10 | contains 11 | subroutine get(this, val) 12 | class(any_vector), intent(in) :: this 13 | character(:), allocatable, intent(out) :: val(:) 14 | select type (this_val => this%val) 15 | type is (character(*)) 16 | val = this_val 17 | end select 18 | end subroutine 19 | end module 20 | 21 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170611c.f90: -------------------------------------------------------------------------------- 1 | ! https://github.com/flang-compiler/flang/issues/96 2 | ! Fixed as of 9/22/2017 3 | 4 | module example 5 | type any_vector 6 | class(*), allocatable :: val(:) 7 | end type 8 | contains 9 | subroutine foo(this) 10 | class(any_vector), intent(in) :: this 11 | integer :: n 12 | select type (this_val => this%val) 13 | type is (character(*)) 14 | do n = 1, size(this_val) 15 | print *, trim(this_val(n)) 16 | end do 17 | end select 18 | end subroutine 19 | end module 20 | 21 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170923a.f90: -------------------------------------------------------------------------------- 1 | ! https://github.com/flang-compiler/flang/issues/237 2 | ! 1/20/2018: ICE fixed, but see flang-20180120.f90 3 | 4 | module example 5 | contains 6 | integer function foo() bind(c,name='') 7 | end function 8 | end module 9 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170923b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/239 2 | !! Fixed as of 3/19/2018, but see flang-20180319{a,b}.f90 3 | !! 4 | !! $ flang -c flang-bug-20170923b.f90 5 | !! F90-F-0155-Empty structure constructor() - type map (flang-bug-20170923b.f90: 12) 6 | !! F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted 7 | 8 | module example 9 | 10 | type :: map 11 | integer, pointer :: first => null() 12 | end type 13 | 14 | type :: parameter_list 15 | type(map) :: params = map() ! this is entirely valid 16 | end type 17 | 18 | end module 19 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170923c.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/240 2 | !! Fixed as of 3/19/2018, but see flang-20180319{a,b}.f90 3 | !! 4 | !! $ flang -c flang-bug-20170923c.f90 5 | !! clang-5.0: error: unable to execute command: Segmentation fault (core dumped) 6 | !! clang-5.0: error: Fortran frontend to LLVM command failed due to signal (use -v to see invocation) 7 | !! clang version 5.0.1 (https://github.com/flang-compiler/clang.git b11539abc46cbd19189c5719d1e30539de3a93b9) (https://github.com/llvm-mirror/llvm.git 81029f142231bde8e119becda112a2173f1459c9) 8 | !! Target: x86_64-unknown-linux-gnu 9 | !! Thread model: posix 10 | !! InstalledDir: /opt/flang/5.0/bin 11 | !! clang-5.0: note: diagnostic msg: PLEASE submit a bug report to and include the crash backtrace, preprocessed source, and associated run script. 12 | !! clang-5.0: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs. 13 | 14 | module map_type 15 | type :: item 16 | type(item), pointer :: next => null() 17 | end type 18 | type :: map 19 | type(item), pointer :: first => null() 20 | end type 21 | type :: parameter_list 22 | type(map) :: params = map() ! this default initializaton causes the ICE 23 | end type 24 | end module 25 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170924a.f90: -------------------------------------------------------------------------------- 1 | ! https://github.com/flang-compiler/flang/issues/241 2 | ! Fixed as of 10/21/2017 3 | 4 | module example 5 | 6 | type :: foo 7 | contains 8 | procedure :: next => foo_next 9 | end type 10 | 11 | type :: bar 12 | type(bar), pointer :: next => null() 13 | end type 14 | 15 | contains 16 | 17 | subroutine foo_next(this) 18 | class(foo) :: this 19 | end subroutine 20 | 21 | subroutine fubar 22 | type(foo) :: obj 23 | call obj%next 24 | end subroutine 25 | 26 | end module 27 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170924b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/243 2 | !! Fully fixed as of 8/12/2018. 3 | !! 4 | !! $ flang -c flang-bug-20170924b.f90 5 | !! F90-F-0155-Too many elements in structure constructor- type foo (flang-bug-20170924b.f90: 5) 6 | !! F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted 7 | !! 8 | !! Incorrect compile error fixed in 543785e (20180615). 9 | !! 10 | !! Example augmented to check result of the assignment. It is incorrect. 11 | !! 12 | !! $ flang flang-20170924b.f90 13 | !! $ ./a.out 14 | !! 2 15 | 16 | type foo 17 | class(*), allocatable :: val 18 | end type 19 | type(foo) :: x 20 | x = foo(42) 21 | select type (val => x%val) 22 | type is (integer) 23 | if (val /= 42) stop 1 24 | class default 25 | stop 2 26 | end select 27 | end 28 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170924c.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/244 2 | !! 3 | !! $ less flang-bug-20170924c.f90 4 | !! $ flang flang-bug-20170924c.f90 5 | !! $ ./a.out 6 | !! T (expect T) 7 | !! 0 (expect 42) 8 | 9 | type foo 10 | class(*), allocatable :: val 11 | end type 12 | type(foo) :: x, y 13 | allocate(x%val, source=42) 14 | y = x 15 | print '(l1,a)', allocated(y%val), ' (expect T)' 16 | if (allocated(y%val)) then 17 | select type (val => y%val) 18 | type is (integer) 19 | print '(i0,a)', val, ' (expect 42)' 20 | class default 21 | print '(a)', 'not expected type' 22 | end select 23 | end if 24 | end 25 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170930a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/254 2 | !! Fixed in the 20190329 release 3 | !! 4 | !! Right shift of bits. 0 should move in from left. 5 | !! 6 | !! Expected output: 7 | !! 8 | !! $ ./a.out 9 | !! -44=11010100 10 | !! 106=01101010 11 | !! 12 | !! Output from flang: 13 | !! 14 | !! $ ./a.out 15 | !! -44=11010100 16 | !! -22=11101010 17 | 18 | program main 19 | use,intrinsic :: iso_fortran_env 20 | integer(int8) :: digest 21 | digest = -44_int8 22 | write(*,'(i0,"=",b8.8)') digest, digest 23 | digest = ishft(digest,-1) 24 | write(*,'(i0,"=",b8.8)') digest, digest 25 | end program 26 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170930b.f90: -------------------------------------------------------------------------------- 1 | ! https://github.com/flang-compiler/flang/issues/253 2 | ! Fixed in the 20190329 release 3 | 4 | program main 5 | 6 | use,intrinsic :: iso_fortran_env 7 | 8 | call int8_arg(iand(1_int8,1_int8)) 9 | call int8_arg(ibset(1_int8,1)) 10 | call int8_arg(ieor(1_int8,1_int8)) 11 | call int8_arg(ior(1_int8,1_int8)) 12 | call int8_arg(ishft(1_int8,1)) 13 | call int8_arg(not(1_int8)) 14 | 15 | contains 16 | 17 | subroutine int8_arg(n) 18 | integer(int8) :: n 19 | end subroutine 20 | 21 | end program 22 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20170930c.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/255 2 | !! Fixed as of 8/12/2018. 3 | !! 4 | !! Execution segfaults at the indicated line. 5 | !! If no final procedure for ITEM, there is no segfault. 6 | !! 7 | !! Test extended to check result after segfault fixed. 8 | 9 | module item_type 10 | 11 | type :: item 12 | class(*), allocatable :: value 13 | contains 14 | final :: item_delete ! NO SEGFAULT IF COMMENTED OUT 15 | end type 16 | 17 | contains 18 | 19 | function new_item(value) 20 | class(*), intent(in) :: value 21 | type(item), pointer :: new_item 22 | allocate(new_item) 23 | !print *, 'before segfault' 24 | allocate(new_item%value, source=value) ! SEGFAULT HERE 25 | !print *, 'after segfault' 26 | end function 27 | 28 | subroutine item_delete(this) 29 | type(item), intent(inout) :: this 30 | print *, 'in final' 31 | end subroutine 32 | 33 | end module 34 | 35 | program main 36 | use item_type 37 | type(item), pointer :: foo 38 | foo => new_item(1) 39 | select type (v => foo%value) 40 | type is (integer) 41 | if (v /= 1) stop 1 42 | class default 43 | stop 2 44 | end select 45 | end program 46 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/307 2 | !! This example now executes correctly with 543785e7 (20180615) 3 | !! 4 | !! $ flang flang-20171122a.f90 5 | !! /tmp/flang-20171122a-6ad8d1.o: In function `MAIN_': 6 | !! flang-20171122a.f90:6: undefined reference to `__f03_unl_poly_0____td_' 7 | !! clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation) 8 | 9 | class(*), allocatable :: val(:) 10 | call get_value (val) 11 | select type (val) 12 | type is (character(*)) 13 | print '(2i2,1x,2a)', len(val), size(val), val ! expect 3 2 foobar 14 | end select 15 | contains 16 | subroutine get_value (value) 17 | class(*), allocatable, intent(out) :: value(:) 18 | allocate(value, source=['foo','bar']) 19 | end subroutine 20 | end 21 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/308 2 | !! Fixed as of 8/12/2018. 3 | !! 4 | !! $ flang flang-20171122b.f90 5 | !! F90-F-0000-Internal compiler error. insert_sym: bad hash 685 (flang-20171122b.f90: 12) 6 | !! F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted 7 | 8 | character(3), target :: a = 'foo' 9 | class(*), pointer :: b 10 | b => ptr() 11 | select type (b) 12 | type is (character(*)) 13 | print '(3a)', 'b="', b, '" (expect "foo")' 14 | end select 15 | contains 16 | function ptr() 17 | class(*), pointer :: ptr 18 | ptr => a 19 | select type (ptr) 20 | type is (character(*)) 21 | end select 22 | end function 23 | end 24 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122c.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/309 2 | !! 3 | !! The following example produces incorrect results. The correct results are: 4 | !! 5 | !! orig= 3 2 1 foobar 6 | !! copy= 3 2 1 foobar 7 | !! 8 | !! But the 2017-11-22 version (3b38c60) gives this: 9 | !! 10 | !! $ flang flang-20171122c.f90 11 | !! $ ./a.out 12 | !! orig= 3 2 1 foobar 13 | !! copy= 3 2 1 fo 14 | !! 15 | 16 | character(:), allocatable :: array(:,:) 17 | array = reshape(['foo','bar'],shape=[2,1]) 18 | call sub (array) 19 | contains 20 | subroutine sub (array) 21 | class(*), intent(in) :: array(:,:) 22 | class(*), allocatable :: copy(:,:) 23 | select type (array) 24 | type is (character(*)) 25 | print '(a,3i2,1x,2a)', 'orig=', len(array), shape(array), array 26 | end select 27 | allocate(copy, source=array) ! SOMETHING GOES WRONG HERE 28 | select type (copy) 29 | type is (character(*)) 30 | print '(a,3i2,1x,2a)', 'copy=', len(copy), shape(copy), copy 31 | end select 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122d.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/308 2 | !! Fixed as of 8/12/2018. 3 | !! 4 | !! This ICE is most likely due to the same problem in flang-20171122b.f90 5 | !! Both ICE's occur at the SELECT TYPE statement where the selector is a 6 | !! CLASS(*) pointer whose dynamic type is CHARACTER. 7 | !! 8 | !! $ flang -c flang-20171122d.f90 9 | !! F90-F-0000-Internal compiler error. insert_sym: bad hash 625 (flang-20171122d.f90: 5) 10 | !! F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted 11 | 12 | function foo() 13 | class(*), pointer :: foo 14 | character(3), target :: string = 'foo' 15 | foo => string 16 | select type (foo) 17 | type is (character(*)) 18 | !print *, foo 19 | end select 20 | end function 21 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122e.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/309 2 | !! This example now executes correctly with 543785e7 (20180615) 3 | !! 4 | !! This example produces incorrect results. Likely the same problem as 5 | !! in flang-20171122c.f90. 6 | !! 7 | !! $ flang flang-20171122e.f90 8 | !! $ ./a.out 9 | !! orig=["fo",""] 10 | !! copy=["fo",""] 11 | 12 | type :: any_vector 13 | class(*), allocatable :: v(:) 14 | end type 15 | type(any_vector) :: x, y 16 | allocate(x%v,source=['foo','bar']) 17 | select type (v => x%v) 18 | type is (character(*)) 19 | print '("orig=[""",a,''","'',a,''"]'')', v ! expect orig=["foo","bar"] 20 | end select 21 | y = x 22 | select type (v => y%v) 23 | type is (character(*)) 24 | print '("copy=[""",a,''","'',a,''"]'')', v ! expect copy=["foo","bar"] 25 | end select 26 | end 27 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122f.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/310 2 | !! 3 | !! POINTER ASSIGNMENT NOT DEFINING DEFERRED LENGTH PARAMETER 4 | !! 5 | !! In the following example, the second pointer assignment involving 6 | !! rank remapping is not properly defining the deferred length parameter 7 | !! of the pointer object (see F2008 5.3.14 #3). Key to the error is 8 | !! that the target is a deferred-length allocatable 9 | !! 10 | !! $ flang flang-20171122f.f90 11 | !! $ ./a.out 12 | !! len1=3 (expect 3) 13 | !! len2=65538 (expect 3) 14 | 15 | program main 16 | character(:), allocatable, target :: array(:) 17 | character(:), pointer :: ptr1(:), ptr2(:,:) 18 | allocate(array(1), source=['foo']) 19 | ptr1 => array ! THIS WORKS 20 | print '(a,2(i0,a))', 'len1=', len(ptr1), ' (expect ', len(array), ')' 21 | ptr2(1:1,1:1) => array ! THIS DOES NOT WORK 22 | print '(a,2(i0,a))', 'len2=', len(ptr2), ' (expect ', len(array), ')' 23 | end program 24 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122g.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/311 2 | !! 3 | !! Flang seems to be completely broken when it comes to pointer 4 | !! rank remapping for CLASS(*) objects. 5 | !! 6 | !! Output from flang: 7 | !! lbound=1 791621423, ubound=4 791621423, shape=4 0 8 | !! 9 | !! Expected output: 10 | !! lbound=1 1, ubound=2 2, shape=2 2 11 | 12 | program main 13 | class(*), allocatable, target :: array(:) 14 | class(*), pointer :: ptr(:,:) 15 | allocate(array, source=[1,2,3,4]) 16 | ptr(1:2,1:2) => array 17 | print '(3(a,i0,1x,i0))', 'lbound=', lbound(ptr), ', ubound=', ubound(ptr), ', shape=', shape(ptr) 18 | end program 19 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171122h.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/312 2 | !! Fixed in the 20190329 release 3 | !! 4 | !! $ flang flang-20171122h.f90 5 | !! F90-S-0000-Internal compiler error. charlen: sym not adjustable-length char 299 (flang-20171122h.f90: 1) 6 | !! F90-S-0000-Internal compiler error. charlen: sym not adjustable-length char 299 (flang-20171122h.f90: 1) 7 | !! 0 inform, 0 warnings, 2 severes, 0 fatal for MAIN 8 | 9 | print '(2a)', elem_raise_case(['a','z']) ! expect XX 10 | contains 11 | elemental function elem_raise_case(s) result(ucs) 12 | character(*), intent(in) :: s 13 | character(len(s)) :: ucs 14 | ucs = repeat('X',len(s)) ! ignore S and just assign fixed string 15 | end function 16 | end program 17 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20171123a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/313 2 | !! 3 | !! $ flang -c flang-20171123a.f90 4 | !! F90-S-0142-size is not a component of this OBJECT (flang-20171123a.f90: 17) 5 | !! F90-S-0075-Subscript, substring, or argument illegal in this context for size (flang-20171123a.f90: 17) 6 | !! F90-S-0155-FUNCTION may not be declared character*(*) when in an INTERFACE - foo_func (flang-20171123a.f90: 14) 7 | !! 0 inform, 0 warnings, 3 severes, 0 fatal for example 8 | !! 9 | !! The first error message concerning the declaration of STRING is erroneous. 10 | 11 | module example 12 | 13 | type, abstract :: foo 14 | contains 15 | procedure(foo_size), deferred :: size 16 | procedure(foo_func), deferred :: func 17 | end type 18 | 19 | abstract interface 20 | pure integer function foo_size (this) 21 | import foo 22 | class(foo), intent(in) :: this 23 | end function 24 | function foo_func (this) result (string) 25 | import :: foo 26 | class(foo) :: this 27 | character(this%size()) :: string 28 | end function 29 | end interface 30 | 31 | end module 32 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20180120.f90: -------------------------------------------------------------------------------- 1 | ! https://github.com/flang-compiler/flang/issues/237 2 | ! 3 | ! This is an modified version of flang-20170923a.f90 4 | ! 5 | ! ICE on the 0-length binding name was fixed in 6d8ef8 but the fix 6 | ! resulted in using "foo" as the binding label (same as no NAME= specifier) 7 | ! when the 2008 standard says "no binding label". Other compilers create a 8 | ! greatly mangled name (as for module procedures) which is in keeping with the 9 | ! spirit of the standard (apparently it seems impossible not to create some 10 | ! object symbol for the procedure). In response, I've added a main program 11 | ! that calls "foo". This should fail to link if the compiler does the right 12 | ! thing. 13 | ! 14 | ! 1/26/2018: Fixed in a972bbd 15 | 16 | module example 17 | contains 18 | integer function foo() bind(c,name='') 19 | end function 20 | end module 21 | 22 | call foo 23 | end 24 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20180319a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/240 2 | !! This adds a PREV component to flang-20170923c.f90 3 | !! Fixed as of 8/12/2018. 4 | !! 5 | !! This is with the 3/19/2018 flang version. 6 | !! 7 | !! $ flang -c flang-20180319a.f90 8 | !! F90-S-0000-Internal compiler error. emit_init:bad dt 54 (flang-20180319a.f90: 20) 9 | !! F90-S-0000-Internal compiler error. assem.c-put_skip old,new not in sync 16 (flang-20180319a.f90: 20) 10 | !! 0 inform, 0 warnings, 2 severes, 0 fatal for map_type 11 | !! 12 | !! New error with 543785e7 (20180615): 13 | !! $ flang -c flang-20180319a.f90 14 | !! /tmp/flang-20180319a-ce0d9c.ll:9:73: error: constant expression type mismatch 15 | !! ...= global %struct_map_type_10_ < { i8* null, [16 x i8] [ i8 0,i8 0,i8 ... 16 | !! ^ 17 | !! 1 error generated. 18 | 19 | module map_type 20 | type :: item 21 | type(item), pointer :: next => null(), prev => null() 22 | end type 23 | type :: map 24 | type(item), pointer :: first => null() 25 | end type 26 | type :: parameter_list 27 | type(map) :: params = map() ! this default initializaton causes the ICE 28 | end type 29 | end module 30 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20180319b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/240 2 | !! This adds a final procedure for ITEM to flang-20180319a.f90 3 | !! 4 | !! This example now compiles with 543785e7 (20180615), however 5 | !! the parent example flang-20180319a.f90 still dies with an ICE. 6 | !! 7 | !! This is with the 3/19/2018 flang version. 8 | !! 9 | !! $ flang -c flang-20180319b.f90 10 | !! F90-F-0155-Empty structure constructor() - type map (flang-20180319b.f90: 20) 11 | !! F90/x86-64 Linux Flang - 1.5 2017-05-01: compilation aborted 12 | 13 | module map_type 14 | type :: item 15 | type(item), pointer :: next => null(), prev => null() 16 | contains 17 | final :: item_delete 18 | end type 19 | type :: map 20 | type(item), pointer :: first => null() 21 | end type 22 | type :: parameter_list 23 | type(map) :: params = map() ! valid empty constructor rejected by flang 24 | end type 25 | contains 26 | subroutine item_delete(this) 27 | type(item), intent(inout) :: this 28 | end subroutine 29 | end module 30 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190503a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/244 2 | !! 3 | !! This is a vector-valued version of flang-20170924c.f90 4 | !! 5 | !! The following example should terminate normally, but instead 6 | !! exits at the STOP 3 statement. 7 | !! 8 | !! $ flang flang-bug-20190503a.f90 9 | !! $ ./a.out 10 | !! 3 11 | 12 | module any_vector_type 13 | 14 | type :: any_vector 15 | class(*), allocatable :: value(:) 16 | end type 17 | 18 | interface any_vector 19 | procedure any_vector_value 20 | end interface 21 | 22 | contains 23 | 24 | function any_vector_value(value) result(obj) 25 | class(*), intent(in) :: value(:) 26 | type(any_vector) :: obj 27 | allocate(obj%value, source=value) 28 | end function 29 | 30 | end module 31 | 32 | program main 33 | use any_vector_type 34 | type(any_vector) :: x 35 | x = any_vector([1,2]) 36 | if (.not.allocated(x%value)) stop 1 37 | select type (v => x%value) 38 | type is (integer) 39 | if (any(v /= [1,2])) stop 2 40 | class default 41 | stop 3 42 | end select 43 | end program 44 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190503b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/244 2 | !! 3 | !! This is a derived type-valued version of flang-20170924c.f90 4 | !! 5 | !! The following example should terminate normally, but instead 6 | !! exits at the STOP 3 statement. 7 | !! 8 | !! $ flang flang-bug-20190503b.f90 9 | !! $ ./a.out 10 | !! 3 11 | 12 | type point 13 | real a, b 14 | end type 15 | 16 | type foo 17 | class(*), allocatable :: val 18 | end type 19 | type(foo) :: x, y 20 | 21 | allocate(x%val, source=point(1.0,2.0)) 22 | y = x 23 | 24 | select type (p => x%val) 25 | type is (point) 26 | if (p%a /= 1.0 .or. p%b /= 2.0) stop 1 27 | class default 28 | stop 2 29 | end select 30 | 31 | select type (p => y%val) 32 | type is (point) 33 | if (p%a /= 1.0 .or. p%b /= 2.0) stop 3 34 | class default 35 | stop 4 36 | end select 37 | 38 | end 39 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190504a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/713 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! With March 2019 binary release: 6 | !! 7 | !! $ flang flang-20190504a.f90 8 | !! F90-S-0000-Internal compiler error. size_of: attempt to get size of assumed size character 0 (flang-20190504a.f90: 15) 9 | !! 0 inform, 0 warnings, 1 severes, 0 fatal for MAIN 10 | !! 11 | 12 | character(:), allocatable :: a(:) 13 | class(*), allocatable :: b(:) 14 | a = ['fubar'] 15 | allocate(b(lbound(a,1):ubound(a,1)), source=a) ! <== ICE HERE 16 | !allocate(b, source=a) ! allowed by F2008 17 | select type (b) 18 | type is (character(*)) 19 | if (len(b) /= 5) stop 1 20 | if (size(b) /= 1) stop 2 21 | if (b(1) /= 'fubar') stop 3 22 | class default 23 | stop 4 24 | end select 25 | end 26 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190504b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/713 2 | !! 3 | !! BAD SOURCED ALLOCATION 4 | !! 5 | !! The following example allocates an unlimited polymorphic array with a SOURCE= 6 | !! argument that is an unlimited polymorphic array whose dynamic type is CHARACTER. 7 | !! With the March 2019 binary release the value of the allocated array is not 8 | !! correctly defined, and the code exits at the STOP 3 statement. (The value is 9 | !! the character 'f' followed by 4 null characters.) 10 | !! 11 | 12 | class(*), allocatable :: b(:) 13 | call foo(['fubar'], b) 14 | contains 15 | subroutine foo(a, b) 16 | class(*), intent(in) :: a(:) 17 | class(*), allocatable :: b(:) 18 | allocate(b(lbound(a,1):ubound(a,1)), source=a) ! <== VALUE OF B NOT CORRECTLY DEFINED 19 | !allocate(b, source=a) ! unspecified bounds allowed by F2008 20 | select type (b) 21 | type is (character(*)) 22 | if (len(b) /= 5) stop 1 23 | if (size(b) /= 1) stop 2 24 | if (b(1) /= 'fubar') stop 3 25 | class default 26 | stop 4 27 | end select 28 | end subroutine 29 | end 30 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190504c.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/713 2 | !! 3 | !! BAD SOURCED ALLOCATION 4 | !! 5 | !! The following example allocates an unlimited polymorphic array with a SOURCE= 6 | !! argument that is an unlimited polymorphic array whose dynamic type is CHARACTER. 7 | !! With the March 2019 binary release the value of the allocated array is not 8 | !! correctly defined, and the code exits at the STOP 3 statement. (The value is 9 | !! the character 'f' followed by 4 null characters.) 10 | !! 11 | 12 | character(:), allocatable :: ref(:,:) 13 | class(*), allocatable :: b(:,:) 14 | ref = reshape(['foo','bar'], shape=[1,2]) 15 | call foo(ref, b) 16 | contains 17 | subroutine foo(a, b) 18 | class(*), intent(in) :: a(:,:) 19 | class(*), allocatable :: b(:,:) 20 | allocate(b(size(a,1),size(a,2)), source=a) ! <== VALUE OF B NOT CORRECTLY DEFINED 21 | !allocate(b, source=a) ! unspecified bounds allowed by F2008 22 | select type (b) 23 | type is (character(*)) 24 | if (len(b) /= len(ref)) stop 1 25 | if (any(shape(b) /= shape(ref))) stop 2 26 | if (any(b /= ref)) stop 3 27 | class default 28 | stop 4 29 | end select 30 | end subroutine 31 | end 32 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190506b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/715 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! The March 2019 binary release gives this ICE on the following example: 6 | !! 7 | !! $ flang flang-20190506b.f90 8 | !! F90-F-0000-Internal compiler error. gen_llvm_expr(): no incoming ili 0 (flang-20190506b.f90: 6) 9 | !! 10 | 11 | type foo 12 | class(*), allocatable :: x 13 | end type 14 | type(foo) :: a 15 | allocate(a%x, source=foo('bizbat')) 16 | end 17 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190506c.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/715 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! The March 2019 binary release gives this ICE on the following example: 6 | !! 7 | !! $ flang flang-20190506b.f90 8 | !! F90-F-0000-Internal compiler error. gen_llvm_expr(): no incoming ili 0 (flang-20190506b.f90: 6) 9 | !! 10 | 11 | type foo 12 | class(*), allocatable :: x 13 | end type 14 | type(foo) :: a 15 | a = foo('bizbat') 16 | end 17 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190511a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/720 2 | !! 3 | !! SEGFAULT ON SOURCED ALLOCATION OF POLYMORPHIC VARIABLE 4 | !! 5 | !! This example seg faults on the sourced allocation statement using 6 | !! the March 2019 binary distribution of flang. 7 | !! 8 | !! The allocation is executed correctly if A is of type JSON_VALUE and not 9 | !! polymorphic. It is also executed correctly if the source is a variable 10 | !! and not an expression. 11 | !! 12 | 13 | type, abstract :: json_value 14 | end type 15 | 16 | type, extends(json_value) :: json_string 17 | character(:), allocatable :: value 18 | end type 19 | 20 | class(json_value), allocatable :: a 21 | 22 | !type(json_string) :: tmp 23 | !tmp%value = 'foo' 24 | !allocate(a, source=tmp) 25 | allocate(a, source=json_string('foo')) ! <== SEG FAULT HERE 26 | 27 | select type(a) 28 | type is (json_string) 29 | if (len(a%value) /= 3) stop 1 30 | if (a%value /= 'foo') stop 2 31 | class default 32 | stop 3 33 | end select 34 | 35 | end 36 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190511b.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/721 2 | !! 3 | !! WRONG RESULT FROM MOVE_ALLOC WITH CHARACTER VARIABLES 4 | !! 5 | !! The MOVE_ALLOC call in this example does not define the value of the result 6 | !! variable B correctly. The example exits on the STOP 2 statement. If you 7 | !! print out LEN(B), it is some random integer value that changes from one 8 | !! execution to the next. This is with the March 2019 binary release. 9 | !! 10 | 11 | character(:), allocatable :: a, b 12 | a = 'foo' 13 | call move_alloc(a, b) 14 | if (.not.allocated(b)) stop 1 15 | if (len(b) /= 3) stop 2 16 | if (b /= 'foo') stop 3 17 | end 18 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190511c.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/722 2 | !! 3 | !! WRONG TYPE FROM POLYMORPHIC SOURCED ALLOCATION WITH MOLD= 4 | !! 5 | !! The following example does a sourced allocation with MOLD= involving 6 | !! CLASS(*) variables. The variable is allocated but its dynamic type is not 7 | !! being defined correctly as required, and execution exits early at the 8 | !! STOP 4 statement. This is with the March 2019 binary release. 9 | !! 10 | 11 | class(*), allocatable :: x, y 12 | 13 | allocate(y, source=42) ! THIS WORKS CORRECTLY 14 | select type (y) 15 | type is (integer) 16 | if (y /= 42) stop 1 17 | class default 18 | stop 2 19 | end select 20 | 21 | allocate(x, mold=y) ! DYNAMIC TYPE OF X NOT DEFINED CORRECTLY 22 | if (.not.allocated(x)) stop 3 23 | select type (x) 24 | type is (integer) 25 | class default 26 | stop 4 ! <== EXITS HERE 27 | end select 28 | 29 | end 30 | -------------------------------------------------------------------------------- /classic-flang-bugs/flang-20190512a.f90: -------------------------------------------------------------------------------- 1 | !! https://github.com/flang-compiler/flang/issues/713 2 | !! 3 | !! LENGTH PARAMETER NOT DEFINED IN CHARACTER-TYPE ALLOCATION OF CLASS(*) 4 | !! 5 | !! The March 2019 binary release does not correctly allocate a class(*) 6 | !! array to character type -- the length parameter is not being defined. 7 | !! The example exits early at the STOP 2 statement. 8 | !! 9 | 10 | class(*), allocatable :: x(:) 11 | character(:), allocatable :: y(:) 12 | 13 | y = ['biz','bat'] 14 | if (len(y) /= 3) stop 1 15 | 16 | !allocate(x(lbound(y,1):ubound(y,1)), source=y) ! SHOULD WORK BUT DOES NOT 17 | 18 | ! ATTEMPT TO WORK AROUND THE ERROR ... 19 | allocate(character(len(y)) :: x(lbound(y,1):ubound(y,1))) 20 | select type (x) 21 | type is (character(*)) 22 | if (len(x) /= len(y)) stop 2 ! <== EXITS HERE -- WRONG LENGTH 23 | class default 24 | stop 3 25 | end select 26 | 27 | end 28 | -------------------------------------------------------------------------------- /flang-bugs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | 3 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake") 4 | include(testing) 5 | 6 | project(flang-bugs Fortran) 7 | 8 | add_compiler_test(NAME flang-20250504 SOURCES mpi_bcast.f90 flang-20250504.F90 RUN_ONLY PASS_REGULAR_EXPRESSION "in mpi_bcast: buffer= 1.[0-9]* 3.[0-9]* 5.[0-9]*") 9 | -------------------------------------------------------------------------------- /flang-bugs/mpi_bcast.f90: -------------------------------------------------------------------------------- 1 | ! Dummy version of MPI_Bcast to dump the received buffer 2 | subroutine mpi_bcast(buffer, count) 3 | integer :: count 4 | real :: buffer(count) 5 | print *, " in mpi_bcast: buffer=", buffer 6 | end subroutine 7 | -------------------------------------------------------------------------------- /gfortran-bugs/char-par-inquiry.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40196 2 | !! Fixed in 12.2.0 and possibly earlier. 3 | !! 4 | !! GFortran 8.0.0 and earlier don't recognize type parameter inquiry for 5 | !! the intrinsic character type. See 6.4.5 (F08) 6 | !! 7 | !! $ gfortran char_par_inquiry.f90 8 | !! char_par_inquiry.f90:6:21: 9 | !! 10 | !! if (size(shape(array%len)) /= 0) stop 1 11 | !! 1 12 | !! Error: Unexpected ‘%’ for nonderived-type variable ‘array’ at (1) 13 | !! char_par_inquiry.f90:7:21: 14 | !! 15 | !! if (size(shape(array%kind)) /= 0) stop 2 16 | !! 1 17 | !! Error: Unexpected ‘%’ for nonderived-type variable ‘array’ at (1) 18 | !! char_par_inquiry.f90:8:10: 19 | !! 20 | !! if (array%kind /= kind(array)) stop 3 21 | !! 1 22 | !! Error: Unexpected ‘%’ for nonderived-type variable ‘array’ at (1) 23 | !! char_par_inquiry.f90:9:10: 24 | !! 25 | !! if (array%len /= len(array)) stop 4 26 | !! 1 27 | !! Error: Unexpected ‘%’ for nonderived-type variable ‘array’ at (1) 28 | 29 | character(5) :: array(10) 30 | if (size(shape(array%len)) /= 0) stop 1 31 | if (size(shape(array%kind)) /= 0) stop 2 32 | if (array%kind /= kind(array)) stop 3 33 | if (array%len /= len(array)) stop 4 34 | end 35 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20100924.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45786 2 | !! 3 | !! Compiler (version ?) incorrectly complains (essentially) that it has 4 | !! no == operator for the operands when in fact it should -- it appears 5 | !! that the defined .EQ. operator is not being treated as the same 6 | !! as == in the module. Error occurs for other equivalent pairs of 7 | !! operators. Here's the compiler error: 8 | !! 9 | !! print *, a == b 10 | !! 1 11 | !! Error: Operands of comparison operator '==' at (1) are TYPE(foo)/TYPE(foo) 12 | 13 | module foo_type 14 | private 15 | public :: foo, operator(==) 16 | type :: foo 17 | integer :: bar 18 | end type 19 | interface operator(.eq.) 20 | module procedure eq_foo 21 | end interface 22 | contains 23 | logical function eq_foo (a, b) 24 | type(foo), intent(in) :: a, b 25 | eq_foo = (a%bar == b%bar) 26 | end function 27 | end module 28 | 29 | subroutine use_it (a, b) 30 | use foo_type 31 | type(foo) :: a, b 32 | print *, a == b 33 | end subroutine 34 | 35 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20100925.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45794 2 | !! Fixed in 12.2.0 and probably much earlier. 3 | !! 4 | !! $ gfortran --version 5 | !! GNU Fortran (GCC) 4.6.0 20100924 (experimental) 6 | !! 7 | !! $ gfortran -c bug3.f90 8 | !! bug3.f90: In function 'foo': 9 | !! bug3.f90:17:0: internal compiler error: Segmentation fault 10 | !! 11 | 12 | subroutine foo (vector, mask) 13 | real :: vector(:) 14 | logical, optional :: mask(:) 15 | integer :: loc(1) 16 | if (present(mask)) then 17 | loc = maxloc(vector, mask) 18 | end if 19 | end subroutine 20 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20110528.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213 2 | !! Finally fixed in gfortran 14.1.0 3 | !! 4 | !! Note that the intrinsic assignment to a polymorphic variable 5 | !! is a F2008 feature (not what this problem report is about). 6 | !! See the F2003 compliant version gfortran-bug-20110528.f90 7 | !! 8 | !! GFortran (version ?) rejects this example with this error: 9 | !! 10 | !! Tobj = T(Sobj) 11 | !! 1 12 | !! Error: Can't convert TYPE(s) to CLASS(s) at (1) 13 | !! 14 | !! Tobj = T(S2obj) 15 | !! 1 16 | !! Error: Can't convert TYPE(s2) to CLASS(s) at (1) 17 | 18 | program main 19 | 20 | type :: S 21 | integer :: n 22 | end type 23 | type(S) :: Sobj 24 | 25 | type, extends(S) :: S2 26 | integer :: m 27 | end type 28 | type(S2) :: S2obj 29 | 30 | type :: T 31 | class(S), allocatable :: x 32 | end type 33 | type(T) :: Tobj 34 | 35 | Sobj = S(1) 36 | Tobj = T(Sobj) 37 | 38 | S2obj = S2(1,2) 39 | Tobj = T(S2obj) 40 | 41 | end program 42 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20110616.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213 2 | !! Finally fixed in gfortran 14.1.0 3 | !! 4 | !! This reworking of gfortran-bug-20110528.f90 is standard F2003. 5 | !! 6 | !! GFortran (version ?) rejects this example with this error: 7 | !! 1 8 | !! call pass_it (T(Sobj)) 9 | !! 1 10 | !! Error: Can't convert TYPE(s) to CLASS(s) at (1) 11 | !! 12 | !! call pass_it (T(S2obj)) 13 | !! 1 14 | !! Error: Can't convert TYPE(s2) to CLASS(s) at (1)!! Internal Compiler Error 15 | !! 16 | 17 | program main 18 | 19 | type :: S 20 | integer :: n 21 | end type 22 | type(S) :: Sobj 23 | 24 | type, extends(S) :: S2 25 | integer :: m 26 | end type 27 | type(S2) :: S2obj 28 | 29 | type :: T 30 | class(S), allocatable :: x 31 | end type 32 | 33 | Sobj = S(1) 34 | call pass_it (T(Sobj)) 35 | 36 | S2obj = S2(1,2) 37 | call pass_it (T(S2obj)) 38 | 39 | contains 40 | 41 | subroutine pass_it (foo) 42 | type(T), intent(in) :: foo 43 | end subroutine 44 | 45 | end program 46 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20120411.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52864 2 | !! Fixed in 12.2.0 and probably much earlier. 3 | !! 4 | !! SYNOPSIS: Application of argument intent to the target of a pointer component 5 | !! 6 | !! The 4.7 gfortran compiler incorrectly interprets argument intent as 7 | !! applying to the target of a argument pointer component, when it only 8 | !! applies to the pointer itself; that is, its association status. 9 | !! 10 | !! % gfortran --version 11 | !! GNU Fortran (GCC) 4.7.0 12 | !! 13 | !! % gfortran gfortran-bug-20120411.f90 14 | !! gfortran-bug-20120411.f90:26.14: 15 | !! 16 | !! call bar (a%ptr) 17 | !! 1 18 | !! Error: Procedure argument at (1) is INTENT(IN) while interface specifies INTENT(INOUT) 19 | !! 20 | 21 | module modA 22 | type :: typeA 23 | integer, pointer :: ptr 24 | end type 25 | contains 26 | subroutine foo (a) 27 | type(typeA), intent(in) :: a 28 | call bar (a%ptr) 29 | end subroutine 30 | subroutine bar (n) 31 | integer, intent(inout) :: n 32 | end subroutine 33 | end module 34 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20150912a.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67560 2 | !! marked a duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67505 3 | !! itself subsequently a duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80361 4 | !! Fixed in 12.2.0 and probably much earlier. 5 | !! 6 | !! $ gfortran --version 7 | !! GNU Fortran (GCC) 5.2.0 8 | !! 9 | !! $ gfortran -fcheck=recursion gfortran-bug-20150912A.f90 10 | !! $ ./a.out 11 | !! At line 20 of file gfortran-bug-20150912A.f90 12 | !! Fortran runtime error: Recursive call to nonrecursive procedure '__final_foo_List' 13 | 14 | module foo 15 | type :: list 16 | type(list), pointer :: next => null() 17 | contains 18 | final :: list_delete 19 | end type 20 | contains 21 | recursive subroutine list_delete (this) 22 | type(list), intent(inout) :: this 23 | if (associated(this%next)) deallocate(this%next) 24 | end subroutine 25 | end module foo 26 | 27 | program main 28 | use foo 29 | type(list), pointer :: x 30 | allocate(x) 31 | allocate(x%next) 32 | deallocate(x) 33 | end program 34 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20150913.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67564 2 | !! Fixed in 12.2.0 and probably much earlier. 3 | !! 4 | !! The following example segfaults on the allocate statement 5 | !! 6 | !! $ gfortran --version gfortran-bug-20150913.f90 7 | !! GNU Fortran (GCC) 6.0.0 20150906 (experimental) 8 | !! 9 | !! $ gfortran gfortran-bug-20150913.f90 10 | !! $ ./a.out 11 | !! 12 | !! Program received signal SIGSEGV: Segmentation fault - invalid memory reference. 13 | !! 14 | !! Backtrace for this error: 15 | !! #0 0x7F338430C517 16 | !! #1 0x7F338430CB5E 17 | !! #2 0x7F338380D95F 18 | !! #3 0x7F33838677ED 19 | !! #4 0x400932 in __copy_character_1.3388 at gfortran-bug-20150913A.f90:? 20 | !! #5 0x400AC6 in MAIN__ at gfortran-bug-20150913A.f90:? 21 | !! Segmentation fault (core dumped) 22 | 23 | program main 24 | type :: any_vector 25 | class(*), allocatable :: x(:) 26 | end type 27 | type(any_vector) :: a 28 | allocate(a%x(2), source=['foo','bar']) 29 | select type (foo => a%x) 30 | type is (character(*)) 31 | print '(a,i0,a)', 'len=', len(foo), ' (expect 3)' 32 | print '(4a)', 'foo=', foo, ' (expect foobar)' 33 | end select 34 | end program 35 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20151101.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68174 2 | !! marked as duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68108 (fixed) 3 | !! Fixed in 12.2.0 and probably much earlier. 4 | !! 5 | !! % gfortran --version 6 | !! GNU Fortran (GCC) 6.0.0 20151025 (experimental) 7 | !! 8 | !! % gfortran -c gfortran-bug-20151101A.f90 9 | !! gfortran-bug-20151101A.f90:15:25: 10 | !! 11 | !! allocate(character(this%maxlen) :: this%mold) 12 | !! 1 13 | !! Error: Scalar INTEGER expression expected at (1) 14 | 15 | module example 16 | 17 | type :: foo 18 | class(*), allocatable :: mold 19 | integer :: maxlen 20 | end type 21 | 22 | contains 23 | 24 | subroutine pop (this) 25 | class(foo), intent(inout) :: this 26 | select type (uptr => this%mold) 27 | type is (character(*)) 28 | deallocate(this%mold) 29 | allocate(character(this%maxlen) :: this%mold) 30 | end select 31 | end subroutine 32 | 33 | end module 34 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20151102a.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54070 2 | !! marked a duplicate of 3 | !! Fixed in 12.2.0 and probably much earlier. 4 | !! 5 | !! Compiled with 6.0 (20151025 snapshot). 6 | !! 7 | !! $ ./a.out 8 | !! len(string)= 5 , size(string)= 2 9 | !! 10 | !! Program received signal SIGSEGV: Segmentation fault - invalid memory reference. 11 | !! 12 | !! Backtrace for this error: 13 | !! #0 0x7FFB05C4E517 14 | !! #1 0x7FFB05C4EB5E 15 | !! #2 0x7FFB0514F95F 16 | !! #3 0x7FFB051B6EC8 17 | !! #4 0x400D23 in fubar.3417 at fubar.f90:? 18 | !! #5 0x400DC9 in MAIN__ at fubar.f90:? 19 | !! Segmentation fault (core dumped) 20 | 21 | program main 22 | character(:), allocatable :: string(:) 23 | call fubar (string) 24 | contains 25 | subroutine fubar (string) 26 | character(:), allocatable, intent(out) :: string(:) 27 | allocate(character(5) :: string(2)) 28 | print *, 'len(string)=', len(string), ', size(string)=', size(string) 29 | string = 'fubar' ! <== SEGMENTATION FAULT HERE 30 | end subroutine 31 | end program 32 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20151102b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54070 2 | !! this example marked a duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50221 3 | !! Fixed in 12.2.0 and probably much earlier. 4 | !! 5 | !! Compiles with 5.2 and 6.0 20151025, but both return the wrong result: 6 | !! barbar (expect "foobar") 7 | !! 8 | 9 | program main 10 | character(:), pointer :: s(:) 11 | allocate(character(3)::s(2)) 12 | s(1) = 'foo'; s(2) = 'bar' 13 | print '(2a)', s ! expect foobar 14 | end program 15 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20160319a.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70312 2 | !! Fixed in 12.2.0 and probably much earlier. 3 | !! 4 | !! duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58175 5 | !! 6 | !! -Wsurprising issues spurious warnings about final procedures. 7 | !! 8 | !! $ gfortran --version 9 | !! GNU Fortran (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) 10 | !! 11 | !! $ gfortran -Wsurprising gfortran-bug-20160319.f90 12 | !! gfortran-bug-20160319.f90:32:6: 13 | !! 14 | !! use foo_type 15 | !! 1 16 | !! Warning: Only array FINAL procedures declared for derived type 'foo' defined at (1), suggest also scalar one [-Wsurprising] 17 | 18 | module foo_type 19 | type foo 20 | contains 21 | final :: foo_delete, foo_delete_2 22 | end type 23 | contains 24 | subroutine foo_delete (this) 25 | type(foo), intent(inout) :: this 26 | end subroutine 27 | subroutine foo_delete_2 (this) 28 | type(foo), intent(inout) :: this(:) 29 | end subroutine 30 | end module 31 | 32 | program main 33 | use foo_type 34 | end program 35 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20160319b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70312 2 | !! Fixed in 12.2.0 and probably much earlier. 3 | !! 4 | !! duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58175 5 | !! 6 | !! -Wsurprising issues spurious warnings about final procedures. 7 | !! 8 | !! $ gfortran --version 9 | !! GNU Fortran (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) 10 | !! 11 | !! $ gfortran -Wsurprising gfortran-bug-20160319.f90 12 | !! gfortran-bug-20160319.f90:29:6: 13 | !! 14 | !! use foo_type 15 | !! 1 16 | !! Warning: Only array FINAL procedures declared for derived type 'foo' defined at (1), suggest also scalar one [-Wsurprising] 17 | 18 | module foo_type 19 | type foo 20 | contains 21 | final :: foo_delete 22 | end type 23 | contains 24 | elemental subroutine foo_delete (this) 25 | type(foo), intent(inout) :: this 26 | end subroutine 27 | end module 28 | 29 | program main 30 | use foo_type 31 | end program 32 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20160320.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67564 2 | !! Fixed in 12.2.0 and probably much earlier 3 | 4 | class(*), allocatable :: val(:) 5 | call get_value (val) 6 | select type (val) 7 | type is (character(*)) 8 | print '(2i2,1x,2a)', len(val), size(val), val ! expect 3 2 foobar 9 | end select 10 | contains 11 | subroutine get_value (value) 12 | class(*), allocatable, intent(out) :: value(:) 13 | allocate(value, source=['foo','bar']) 14 | end subroutine 15 | end 16 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20160321.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 12.2.0 and probably much earlier 2 | 3 | character(:), allocatable :: array(:,:) 4 | array = reshape(['foo','bar'],shape=[2,1]) 5 | call sub (array) 6 | contains 7 | subroutine sub (array) 8 | class(*), intent(in) :: array(:,:) 9 | class(*), allocatable :: copy(:,:) 10 | select type (array) 11 | type is (character(*)) 12 | print '(a,3i2,1x,2a)', 'orig=', len(array), shape(array), array 13 | end select 14 | allocate(copy, source=array) 15 | select type (copy) 16 | type is (character(*)) 17 | print '(a,3i2,1x,2a)', 'copy=', len(copy), shape(copy), copy 18 | end select 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20170112a.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79072 2 | !! fixed in 254966 (2017-11-20) 3 | !! 4 | !! This example gives an ICE with the current 7.0 trunk and all 6.x releases 5 | !! 6 | !! The ICE disappears if either: 7 | !! 1) type is (character(*)) is replaced with integer, for example; 8 | !! 2) the return variable is specified in a result(...) clause. 9 | !! 10 | 11 | function foo() 12 | class(*), pointer :: foo 13 | character(3), target :: string = 'foo' 14 | foo => string 15 | select type (foo) 16 | type is (character(*)) 17 | !print *, foo 18 | end select 19 | end function 20 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20170112b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79072 2 | !! fixed in 254966 (2017-11-20) 3 | !! 4 | !! It gives correct results with 6.3: 5 | !! 5 fubar 6 | !! 5 fubar 7 | !! 8 | !! But incorrect results with 7.0 development branch: 9 | !! 5 fubar 10 | !! 0 11 | 12 | program main 13 | 14 | class(*), pointer :: x, y 15 | allocate(x, source='fubar') 16 | 17 | y => foobar(x) 18 | 19 | select type (y) 20 | type is (character(*)) 21 | print '(i0,1x,a)', len(y), y 22 | end select 23 | 24 | contains 25 | 26 | function foobar(bar) result(foo) 27 | class(*), pointer :: foo, bar 28 | foo => bar 29 | !select type (foo) 30 | !type is (character(*)) 31 | ! print *, len(foo), foo 32 | !end select 33 | end function 34 | 35 | end program 36 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20170812a.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79072 2 | !! fixed in 254966 (2017-11-20) 3 | !! 4 | !! $ gfortran --version 5 | !! GNU Fortran (GCC) 7.2.1 20171028 6 | !! 7 | !! $ gfortran gfortran-bug-20170812a.f90 8 | !! $ ./a.out 9 | !! b="" (expect "foo") 10 | 11 | character(3), target :: a = 'foo' 12 | class(*), pointer :: b 13 | b => ptr() 14 | select type (b) 15 | type is (character(*)) 16 | print '(3a)', 'b="', b, '" (expect "foo")' 17 | end select 18 | contains 19 | function ptr() 20 | class(*), pointer :: ptr 21 | ptr => a 22 | end function 23 | end 24 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171114b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82996 2 | !! Fixed in 12.2.0 and possibly earlier 3 | !! 4 | !! The original example gave an error when automatically applying the 5 | !! elemental final procedure to the B array component of the BAR object. 6 | !! So let's add a final procedure to the BAR type (not necessary) that 7 | !! explicitly calls FOO_DESTROY on the B array component. Here's what 8 | !! happens: 9 | !! 10 | !! $ gfortran -g gfortran-bug-20171114b.f90 11 | !! f951: internal compiler error: in generate_finalization_wrapper, at fortran/class.c:1975 12 | !! Please submit a full bug report, 13 | !! with preprocessed source if appropriate. 14 | !! See for instructions. 15 | 16 | module mod 17 | 18 | type foo 19 | integer, pointer :: f(:) => null() 20 | contains 21 | final :: foo_destroy 22 | end type 23 | 24 | type bar 25 | type(foo) :: b(2) 26 | contains 27 | final :: bar_destroy 28 | end type 29 | 30 | contains 31 | 32 | elemental subroutine foo_destroy(this) 33 | type(foo), intent(inout) :: this 34 | if (associated(this%f)) deallocate(this%f) 35 | end subroutine 36 | 37 | subroutine bar_destroy(this) 38 | type(bar), intent(inout) :: this 39 | call foo_destroy(this%b) 40 | end subroutine 41 | 42 | end module 43 | 44 | program main 45 | 46 | use mod 47 | type(bar) :: x 48 | call sub(x) 49 | 50 | contains 51 | 52 | subroutine sub(x) 53 | type(bar), intent(out) :: x 54 | end subroutine 55 | 56 | end program 57 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171115.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83012 2 | !! fixed in 254914 (2017-11-18) 3 | !! 4 | !! In this example the pointer assignment p => x%dataptr() is rejected 5 | !! because the compiler does not recognize the function result x%dataptr() 6 | !! as contiguous when in fact it is simply contiguous by definition. 7 | !! Note that there is no error if the dummy variable x is declared as 8 | !! type(foo) instead of class(foo). 9 | !! 10 | !! $ gfortran --version 11 | !! GNU Fortran (GCC) 8.0.0 20171115 (experimental) 12 | !! 13 | !! $ gfortran -c bug.f90 14 | !! bug.f90:19:7: 15 | !! 16 | !! p => x%dataptr() 17 | !! 1 18 | !! Error: Assignment to contiguous pointer from non-contiguous target at (1) 19 | 20 | module mod 21 | type :: foo 22 | integer, pointer, contiguous :: p(:) 23 | contains 24 | procedure :: dataptr 25 | end type 26 | contains 27 | function dataptr(this) result(dp) 28 | class(foo), intent(in) :: this 29 | integer, pointer, contiguous :: dp(:) 30 | dp => this%p 31 | end function 32 | end module 33 | 34 | subroutine bar(x) 35 | use mod 36 | class(foo) :: x 37 | integer, pointer, contiguous :: p(:) 38 | p => x%dataptr() 39 | end subroutine 40 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171122.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83118 2 | !! Fixed in 8.0 r258438 (3/11/2018) 3 | !! 4 | !! [REGRESSION] Intrinsic assignment of derived type with class(*) array 5 | !! component is not done correctly when the dynamic type is character. 6 | !! 7 | !! Version 6.4.1 gives the expected result: 8 | !! 9 | !! $ gfortran --version 10 | !! GNU Fortran (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) 11 | !! 12 | !! $ gfortran gfortran-bug-20171122.f90 13 | !! $ ./a.out 14 | !! orig=["foo","bar"] 15 | !! copy=["foo","bar"] 16 | !! 17 | !! But 8.0.0 gives an incorrect result: 18 | !! 19 | !! $ gcc --version 20 | !! gcc (GCC) 8.0.0 20171122 (experimental) 21 | !! 22 | !! $ gfortran gfortran-bug-20171122.f90 23 | !! $ ./a.out 24 | !! orig=["foo","bar"] 25 | !! copy=["foo","b"] 26 | !! 27 | 28 | type :: any_vector 29 | class(*), allocatable :: v(:) 30 | end type 31 | type(any_vector) :: x, y 32 | allocate(x%v,source=['foo','bar']) 33 | select type (v => x%v) 34 | type is (character(*)) 35 | print '("orig=[""",a,''","'',a,''"]'')', v ! expect orig=["foo","bar"] 36 | end select 37 | y = x ! THIS ASSIGNMENT IS NOT BEING DONE CORRECTLY 38 | select type (v => y%v) 39 | type is (character(*)) 40 | print '("copy=[""",a,''","'',a,''"]'')', v ! expect copy=["foo","bar"] 41 | end select 42 | end 43 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171122b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83118 2 | !! Fixed in 8.2.0, but bug remains open due to sparc issue. 3 | !! 4 | !! [REGRESSION] Intrinsic assignment of derived type with class(*) array 5 | !! component is not done correctly when the dynamic type is character. 6 | !! 7 | !! This variation of gfortran-20171122.f90 replaces the initial sourced 8 | !! allocation with a direct assignment. This generates a segfault with 9 | !! the 8.0 trunk and 7.0 trunk. 10 | !! 11 | !! $ gfortran --version 12 | !! GNU Fortran (GCC) 8.0.1 20180224 (experimental) 13 | !! 14 | !! $ gfortran -g -fbacktrace gfortran-20171122b.f90 15 | !! $ ./a.out 16 | !! 17 | !! Program received signal SIGSEGV: Segmentation fault - invalid memory reference. 18 | !! 19 | !! Backtrace for this error: 20 | !! #0 0x7ff54eb3294f in ??? 21 | !! #1 0x0 in ??? 22 | !! Segmentation fault (core dumped) 23 | 24 | type :: any_vector 25 | class(*), allocatable :: v(:) 26 | end type 27 | type(any_vector) :: x, y 28 | !allocate(x%v,source=['foo','bar']) 29 | x%v = ['foo','bar'] 30 | select type (v => x%v) 31 | type is (character(*)) 32 | print '("orig=[""",a,''","'',a,''"]'')', v ! expect orig=["foo","bar"] 33 | end select 34 | y = x ! THIS ASSIGNMENT IS NOT BEING DONE CORRECTLY 35 | select type (v => y%v) 36 | type is (character(*)) 37 | print '("copy=[""",a,''","'',a,''"]'')', v ! expect copy=["foo","bar"] 38 | end select 39 | end 40 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171124b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213 2 | !! Finally fixed in gfortran 14.1.0 3 | !! 4 | !! Another case of gfortran-bug-20110616.f90. GFortran seems to be 5 | !! fundamentally broken when it comes to derived types with polymorphic 6 | !! pointer components and intrinsic structure constructors. 7 | !! 8 | !! $ gfortran gfortran-20171124b.f90 9 | !! gfortran-20171124b.f90:6:13: 10 | !! 11 | !! call sub(box(n)) 12 | !! 1 13 | !! Error: Can't convert INTEGER(4) to CLASS(*) at (1) 14 | 15 | type box 16 | class(*), pointer :: uptr => null() 17 | end type 18 | integer, target :: n 19 | call sub(box(n)) 20 | contains 21 | subroutine sub(b) 22 | type(box), intent(in) :: b 23 | end subroutine 24 | end 25 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171124d.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79929 2 | !! Fixed in 12.2.0 and probably earlier 3 | !! 4 | !! According to the comments on the PR, these are bogus warning messages. 5 | !! They occur with 8.0 (20171123) at -O1 and higher optimization levels, 6 | !! and with 7.2.1 at -O2 and higher. They do not occur with 6.4.1. 7 | !! 8 | !! $ gfortran -O1 -c bug.f90 9 | !! bug.f90:3:0: 10 | !! 11 | !! errmsg = 'unable to initialize region: ' // trim(errmsg) 12 | !! 13 | !! Warning: '__builtin_memset' specified size 18446744073709551587 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] 14 | 15 | subroutine sub2(errmsg) 16 | character(*) :: errmsg 17 | errmsg = 'foo: ' // trim(errmsg) 18 | end subroutine 19 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171124e-main.f90: -------------------------------------------------------------------------------- 1 | use mod 2 | string = 'fubar' 3 | select case (get_string()) 4 | case default 5 | end select 6 | end 7 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20171124f-main.f90: -------------------------------------------------------------------------------- 1 | subroutine sub 2 | use mod2 3 | s = size(get()) 4 | print *, s 5 | end 6 | 7 | ! example main program 8 | !use mod1 9 | !ncells = 10 10 | !call sub 11 | !ncells = 20 12 | !call sub 13 | !end 14 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180128.f90: -------------------------------------------------------------------------------- 1 | !! PR 84093 2 | !! 3 | !! A compiler should return an error for this invalid code, 4 | !! However gfortran does not. 5 | !! 6 | 7 | type parent 8 | integer :: a, b 9 | end type 10 | 11 | type, extends(parent) :: child 12 | real :: x 13 | end type 14 | 15 | type(child) :: foo 16 | 17 | foo = child(parent(1,2),3.0) ! INVALID -- SEE NOTE 4.59 (F08 or F15) 18 | foo = child(parent=parent(1,2), x=3.0) ! THIS IS CORRECT 19 | 20 | end 21 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180129.f90: -------------------------------------------------------------------------------- 1 | !! PR 84093 2 | !! 3 | !! This is a companion to gfortran-20180129.f90, which compilers should reject 4 | !! with an error. This is valid code which run without error, but doesn't with 5 | !! gfortran 8.0 and earlier. 6 | !! 7 | !! $ gfortran gfortran-20180129.f90 8 | !! $ ./a.out 9 | !! STOP 2 10 | 11 | type parent 12 | type(parent), pointer :: next => null() 13 | end type 14 | 15 | type, extends(parent) :: child 16 | integer :: n 17 | end type 18 | 19 | type(child) :: c 20 | type(parent), pointer :: p 21 | 22 | allocate(p) 23 | allocate(p%next) 24 | 25 | c = child(parent=p,n=1) 26 | if (.not.associated(c%next,p%next)) stop 1 27 | 28 | c = child(p,1) 29 | if (.not.associated(c%next,p)) stop 2 30 | 31 | end 32 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180130a.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84119 2 | !! 3 | !! TYPE PARAMETER INQUIRY SHOULD ALWAYS RETURN A SCALAR 4 | !! 5 | !! See Note 6.7 (F08). GFortran 8.0 returns an array when the designator 6 | !! is an array, essentially treating type inquiry as a reference to a 7 | !! component of the type; same syntax, but not the same thing. 8 | !! 9 | !! $ gfortran --version 10 | !! GNU Fortran (GCC) 8.0.0 20171227 (experimental) 11 | !! $ gfortran gfortran-20180130a.f90 12 | !! $ ./a.out 13 | !! STOP 1 14 | 15 | type :: vector(dim,kind) 16 | integer, len :: dim 17 | integer, kind :: kind 18 | end type 19 | type(vector(3,1)) :: a(10) 20 | if (size(shape(a%dim)) /= 0) stop 1 21 | if (size(shape(a%kind)) /= 0) stop 2 22 | end 23 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180130b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84120 2 | !! 3 | !! INVALID SYNTAX FOR PDT CONSTRUCTOR 4 | !! 5 | !! GFortran uses an invalid syntax for PDT constructors in which the type 6 | !! parameters are regarded as a component of the derived type. See R455 for 7 | !! the constructor syntax (F08 standard), and R453 for the derived-type-spec. 8 | !! Note that 1.3.33 defines what a "component" is, and it does not include 9 | !! type parameters. The following example is invalid and should be rejected 10 | !! by the compiler; gfortran accepts it, and runs without error. 11 | !! 12 | !! $ gfortran --version 13 | !! GNU Fortran (GCC) 8.0.0 20171227 (experimental) 14 | !! $ gfortran gfortran-20180130b.f90 15 | !! $ ./a.out && echo OKAY 16 | !! OKAY 17 | 18 | type foo(dim) 19 | integer,len :: dim 20 | integer :: array(dim) 21 | end type 22 | type(foo(:)), allocatable :: x 23 | x = foo(2,[1,2]) ! INVALID SYNTAX THAT GFORTRAN USES 24 | if (size(x%array) /= 2) stop 1 25 | if (any(x%array /= [1,2])) stop 2 26 | end 27 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180130c.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84120 2 | !! 3 | !! GFORTRAN REJECTS VALID SYNTAX FOR PDT CONSTRUCTOR 4 | !! 5 | !! The is the "correct syntax" version of gfortran-20180130b.f90. 6 | !! GFortran 8.0 rejects it. 7 | !! 8 | !! $ gfortran --version 9 | !! GNU Fortran (GCC) 8.0.0 20171227 (experimental) 10 | !! $ gfortran gfortran-20180130c.f90 11 | !! gfortran-20180130c.f90:22:9: 12 | !! 13 | !! x = foo(2)([1,2]) 14 | !! 1 15 | !! Error: Invalid character in name at (1) 16 | 17 | type foo(dim) 18 | integer,len :: dim 19 | integer :: array(dim) 20 | end type 21 | type(foo(:)), allocatable :: x 22 | x = foo(2)([1,2]) 23 | if (size(x%array) /= 2) stop 1 24 | if (any(x%array /= [1,2])) stop 2 25 | end 26 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180130d.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84122 2 | !! 3 | !! REJECTS VALID STATEMENT SEQUENCE IN PDT DEFINITION 4 | !! 5 | !! The PRIVATE statement comes after any type parameter declarations; 6 | !! see R425 (F08). GFortran 8.0 rejects this valid example. It regards the 7 | !! type parameters as regular components (they are not), and so wants the 8 | !! PRIVATE statement before them. 9 | !! 10 | !! $ gfortran --version 11 | !! GNU Fortran (GCC) 8.0.0 20171227 (experimental) 12 | !! $ gfortran gfortran-20180130d.f90 13 | !! gfortran-20180130d.f90:22:9: 14 | !! 15 | !! private 16 | !! 1 17 | !! Error: PRIVATE statement at (1) must precede structure components 18 | 19 | module mod 20 | type foo(dim) 21 | integer,len :: dim 22 | private 23 | integer :: array(dim) 24 | end type 25 | end module 26 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180130e.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84143 2 | !! Working in 12.2.0 (and perhaps earlier) 3 | !! 4 | !! INTRINSIC OUTPUT OF PDT INCORRECTLY INCLUDES TYPE PARAMETERS 5 | !! 6 | !! Type parameters are not components (see F08 1.3.33, R435, and cf R431) 7 | !! and therefore should not be included in the intrinsic output of a PDT. 8 | !! But gfortran 8.0 includes the type parameters and so exits on the STOP 1 9 | 10 | type foo(k1,l1) 11 | integer,kind :: k1=1 12 | integer,len :: l1=2 13 | integer :: n=3 14 | end type 15 | 16 | type(foo) :: x 17 | character(8) :: string 18 | 19 | write(string,'(*(i0))') x ! THIS SHOULD WRITE THE SINGLE DIGIT 3 20 | if (len_trim(string) /= 1) stop 1 21 | end 22 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180223b.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84539 2 | !! 3 | !! Fixed on the 9.0 trunk, but persists on 8. 4 | !! 5 | !! SEGFAULT ON ASSIGNMENT TO CLASS(*) ALLOCATABLE ARRAY 6 | !! 7 | !! $ gfortran --version 8 | !! GNU Fortran (GCC) 8.0.1 20180224 (experimental) 9 | !! $ gfortran -g -fbacktrace gfortran-20180223b.f90 10 | !! $ ./a.out 11 | !! 12 | !! Program received signal SIGSEGV: Segmentation fault - invalid memory reference. 13 | !! 14 | !! Backtrace for this error: 15 | !! #0 0x7f908609b94f in ??? 16 | !! #1 0x400853 in MAIN__ 17 | !! at gfortran-20180223b.f90:21 18 | !! #2 0x4009fd in main 19 | !! at gfortran-20180223b.f90:26 20 | !! Segmentation fault (core dumped) 21 | 22 | class(*), allocatable :: x(:) 23 | x = ['foo','bar'] ! SEGFAULT HERE 24 | select type (x) 25 | type is (character(*)) 26 | if (any(x /= ['foo','bar'])) stop 1 27 | end select 28 | end 29 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180224.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84546 2 | !! Fixed in 8.0 r258438 (3/11/2018) 3 | !! 4 | !! BAD SOURCED ALLOCATION -- 7/8 REGRESSION 5 | !! 6 | !! This example has a similar theme to several past bugs: character arrays, 7 | !! CLASS(*) allocatable variables, character length parameters not being 8 | !! propagated correctly. The correct output is "foobar", but the current 9 | !! 7/8 trunks produce "foob". Version 6.4.1 works properly. 10 | !! 11 | 12 | module any_vector_type 13 | 14 | type :: any_vector 15 | class(*), allocatable :: vec(:) 16 | end type 17 | 18 | interface any_vector 19 | procedure any_vector1 20 | end interface 21 | 22 | contains 23 | 24 | function any_vector1(vec) result(this) 25 | class(*), intent(in) :: vec(:) 26 | type(any_vector) :: this 27 | allocate(this%vec, source=vec) 28 | end function 29 | 30 | end module 31 | 32 | program main 33 | 34 | use any_vector_type 35 | implicit none 36 | 37 | class(*), allocatable :: x 38 | character(*), parameter :: vec(*) = ['foo','bar'] 39 | 40 | allocate(x, source=any_vector(vec)) 41 | 42 | select type (x) 43 | type is (any_vector) 44 | select type (xvec => x%vec) 45 | type is (character(*)) 46 | print *, xvec ! EXPECT "foobar" 47 | if (any(xvec /= vec)) stop 1 48 | end select 49 | end select 50 | 51 | end program 52 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20180610.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100 2 | !! Finally fixed in gfortran 14.2.0 3 | !! 4 | !! SPURIOUS RUNTIME ERROR WITH -fcheck=bounds AND CLASS(*) ARRAY COMPONENTS 5 | !! 6 | !! Executes correctly without -fcheck=bounds. Also executes correctly if 7 | !! the array component is rank 1, or if it is INTEGER instead of CLASS(*). 8 | !! So seems confined to rank-2 (or greater?) allocatable CLASS(*) components. 9 | !! 10 | !! $ gfortran --version 11 | !! GNU Fortran (GCC) 8.1.1 20180531 12 | !! 13 | !! $ gfortran -g -fcheck=bounds gfortran-20180610.f90 14 | !! $ ./a.out 15 | !! At line 16 of file gfortran-20180610.f90 16 | !! Fortran runtime error: Array bound mismatch for dimension 1 of array '<>' (2/1) 17 | !! 18 | !! Error termination. Backtrace: 19 | !! #0 0x4014d1 in MAIN__ 20 | !! at .../gfortran-20180610.f90:26 21 | !! #1 0x401c87 in main 22 | !! at .../gfortran-20180610.f90:34 23 | 24 | type any_matrix 25 | class(*), allocatable :: m(:,:) 26 | end type 27 | type(any_matrix) :: a, b 28 | allocate(a%m, source=reshape([3,5],shape=[1,2])) 29 | b = a ! SPURIOUS RUNTIME ERROR with -fcheck=bounds 30 | 31 | select type (m => b%m) ! CHECK THE COPY 32 | type is (integer) 33 | if (any(m /= reshape([3,5],shape=[1,2]))) stop 1 34 | class default 35 | stop 2 36 | end select 37 | end 38 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20190202.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89174 2 | !! Working in 12.2.0 and likely earlier. 3 | !! 4 | !! REGRESSION -- ALLOCATION SEGFAULT WITH CLASS(*) MOLD 5 | !! 6 | !! Used to work with earlier 8.2.1 snapshots and probably 9.0 as well, 7 | !! but fails now with both 8.2.1 and 9.0. Works fine with 7.3.1. 8 | !! 9 | 10 | module mod 11 | type :: array_data 12 | class(*), allocatable :: mold 13 | contains 14 | procedure :: push 15 | end type 16 | contains 17 | subroutine push(this, value) 18 | class(array_data), intent(inout) :: this 19 | class(*), intent(in) :: value 20 | allocate(this%mold, mold=value) ! <== SEGFAULTS HERE 21 | end subroutine 22 | end module 23 | 24 | use mod 25 | type(array_data) :: foo 26 | call foo%push(42) 27 | end 28 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20200402-file1.f90: -------------------------------------------------------------------------------- 1 | ! See gfortran-20200402-file2.f90 for description 2 | 3 | module scalar_func_class 4 | type, abstract :: scalar_func 5 | end type 6 | end module 7 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20200402-file2.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94463 2 | !! 3 | !! LINK FAILURE 4 | !! 5 | !! In this example the compiler generates a reference to the undefined 6 | !! symbol __vtab_scalar_func_class_Scalar_func.3804. The example is split 7 | !! across two source files (see gfortran-20200402-file1.f90). Note that 8 | !! the symbol __scalar_func_class_MOD___vtab_scalar_func_class_Scalar_func 9 | !! is defined in gfortran-20200402-file1.o. 10 | !! 11 | !! This failure appears to occur for all versions of gfortran. 12 | !! 13 | !! $ gfortran gfortran-20200402-file1.f90 -c 14 | !! $ gfortran gfortran-20200402-file2.f90 gfortran-20200402-file1.o 15 | !! /usr/bin/ld: /tmp/ccNS7CfH.o: in function `__fubar_MOD_edit_short': 16 | !! gfortran-20200402-file2.f90:(.text+0x1f): undefined reference to `__vtab_scalar_func_class_Scalar_func.3905' 17 | !! /usr/bin/ld: gfortran-20200402-file2.f90:(.text+0x8f): undefined reference to `__vtab_scalar_func_class_Scalar_func.3905' 18 | !! collect2: error: ld returned 1 exit status 19 | !! 20 | 21 | module material_model_type 22 | contains 23 | subroutine alloc_phase_prop(func) 24 | use scalar_func_class, only: scalar_func 25 | class(scalar_func), allocatable, intent(out) :: func 26 | end subroutine 27 | end module 28 | 29 | module fubar 30 | contains 31 | subroutine edit_short 32 | use material_model_type, only: alloc_phase_prop 33 | use scalar_func_class, only: scalar_func 34 | class(scalar_func), allocatable :: f 35 | call alloc_phase_prop(f) 36 | end subroutine 37 | end module 38 | 39 | end 40 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20200501.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94909 2 | !! 3 | !! REJECTS VALID CODE 4 | !! 5 | !! There is no recursion here. 6 | !! 7 | !! $ gfortran --version 8 | !! GNU Fortran (GCC) 9.3.0 9 | !! 10 | !! $ gfortran -c gfortran-20200501.f90 11 | !! gfortran-20200501.f90:13:10: 12 | !! 13 | !! 13 | dot = a%dot_(b) 14 | !! | 1 15 | !! Error: Function 'dot' at (1) cannot be called recursively, as it is not RECURSIVE 16 | !! 17 | 18 | module example 19 | 20 | type, abstract :: foo 21 | contains 22 | procedure :: dot 23 | procedure(dot), deferred :: dot_ 24 | end type 25 | 26 | contains 27 | 28 | function dot(a, b) 29 | class(foo) :: a, b 30 | dot = a%dot_(b) 31 | end function 32 | 33 | end module 34 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20210527.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100815; fixed in 12.2 (and perhaps earlier) 2 | !! 3 | !! SEGFAULT IN ASSIGNMENT TO SCALAR ALLOCATABLE POLYMORPHIC LHS 4 | !! 5 | !! This is a regression that was introduced in version 11 6 | !! 7 | !! $ gfortran --version 8 | !! GNU Fortran (GCC) 11.1.1 20210527 9 | !! 10 | !! $ gfortran -g -O0 gfortran-20210527.f90 11 | !! $ ./a.out 12 | !! 13 | !! Program received signal SIGSEGV: Segmentation fault - invalid memory reference. 14 | !! 15 | !! Backtrace for this error: 16 | !! #0 0x7f77e9546a6f in ??? 17 | !! #1 0x401405 in MAIN__ 18 | !! at /home/nnc/Fortran/fortran-compiler-tests/gfortran-bugs/gfortran-20210527.f90:41 19 | !! #2 0x401741 in main 20 | !! at /home/nnc/Fortran/fortran-compiler-tests/gfortran-bugs/gfortran-20210527.f90:43 21 | !! Segmentation fault (core dumped) 22 | !! 23 | 24 | type, abstract :: func 25 | end type 26 | 27 | type, extends(func) :: const_func 28 | real :: c = 0.0 29 | end type 30 | 31 | type :: func_box 32 | class(func), allocatable :: f 33 | end type 34 | 35 | type :: foo 36 | type(func_box), allocatable :: farray(:) 37 | end type 38 | 39 | type(const_func) :: f 40 | type(foo) :: this 41 | 42 | allocate(this%farray(2)) 43 | this%farray(size(this%farray))%f = f 44 | 45 | end 46 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20211123.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103394 2 | !! 3 | !! GFortran 11.2 and earlier, including the current 12.0 development 4 | !! all generate bad object code for the foo_vector_func(...) structure 5 | !! constructor expression below. The program should exit normally but 6 | !! instead bails at the "stop 1" statement. 7 | !! 8 | 9 | module foo_type 10 | 11 | type :: foo 12 | contains 13 | procedure :: alloc_foo_vector_func 14 | end type 15 | 16 | type, abstract :: vector_func 17 | end type 18 | 19 | type, extends(vector_func) :: foo_vector_func 20 | type(foo), pointer :: ptr 21 | end type 22 | 23 | contains 24 | 25 | subroutine alloc_foo_vector_func(this, vf) 26 | class(foo), intent(in), target :: this 27 | class(vector_func), allocatable, intent(out) :: vf 28 | allocate(vf, source=foo_vector_func(this)) ! DOESN'T WORK CORRECTLY 29 | !vf = foo_vector_func(this) ! DOESN'T WORK EITHER 30 | end subroutine 31 | 32 | end module 33 | 34 | program main 35 | use foo_type 36 | type(foo), target :: x 37 | class(vector_func), allocatable :: vf 38 | call x%alloc_foo_vector_func(vf) 39 | select type (vf) 40 | type is (foo_vector_func) 41 | if (.not.associated(vf%ptr, x)) stop 1 ! SHOULD NOT EXIT HERE 42 | end select 43 | end program 44 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20220128.f90: -------------------------------------------------------------------------------- 1 | !! Reported to OpenCoarrays: https://github.com/sourceryinstitute/OpenCoarrays/issues/749 2 | !! 3 | !! DOUBLE FREE SIGABORT FROM COARRAY DEALLOCATION 4 | !! 5 | !! The following example triggers a double free SIGABRT when the coarray 6 | !! with an allocatable component is automatically deallocated. Happens 7 | !! with any number of images, including just 1. 8 | !! 9 | !! $ caf --version 10 | !! OpenCoarrays Coarray Fortran Compiler Wrapper (caf version 2.9.2-13-g235167d) 11 | !! 12 | !! $ gfortran --version 13 | !! GNU Fortran (GCC) 11.2.0 14 | !! 15 | !! $ caf gfortran-20220128.f90 16 | !! 17 | !! $ cafrun -n 1 ./a.out 18 | !! free(): double free detected in tcache 2 19 | !! Program received signal SIGABRT: Process abort signal. 20 | !! 21 | 22 | program main 23 | 24 | integer :: array(10) 25 | call sub(array) 26 | 27 | contains 28 | 29 | subroutine sub(array) 30 | integer, intent(in) :: array(:) 31 | type :: box 32 | integer, allocatable :: array(:) 33 | end type 34 | type(box), allocatable :: buffer[:] 35 | allocate(buffer[*]) 36 | buffer%array = array 37 | end subroutine 38 | 39 | end program 40 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20220221-main.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104630 2 | !! 3 | !! MODULE SUBROUTINE NOT ACCESSIBLE FROM SUBMODULE 4 | !! 5 | !! Host procedures should be accessible from submodules of the host. 6 | !! If the three program units are combined in a single file there is no error. 7 | !! 8 | !! $ gfortran gfortran-20220221-{module,submodule,main}.f90 9 | !! /usr/bin/ld: /tmp/ccrtpWxQ.o: in function `__moda_MOD_foo': 10 | !! gfortran-20220221-submodule.f90:(.text+0x17): undefined reference to `__moda_MOD_bar' 11 | !! collect2: error: ld returned 1 exit status 12 | 13 | use modA 14 | end 15 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20220221-module.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104630 2 | !! 3 | !! MODULE SUBROUTINE NOT ACCESSIBLE FROM SUBMODULE 4 | !! 5 | !! Host procedures should be accessible from submodules of the host. 6 | !! If the three program units are combined in a single file there is no error. 7 | !! 8 | !! $ gfortran gfortran-20220221-{module,submodule,main}.f90 9 | !! /usr/bin/ld: /tmp/ccrtpWxQ.o: in function `__moda_MOD_foo': 10 | !! gfortran-20220221-submodule.f90:(.text+0x17): undefined reference to `__moda_MOD_bar' 11 | !! collect2: error: ld returned 1 exit status 12 | 13 | module modA 14 | private 15 | type, public :: typeA 16 | contains 17 | procedure :: foo 18 | end type 19 | interface 20 | module subroutine foo(this) 21 | class(typeA) :: this 22 | end subroutine 23 | end interface 24 | contains 25 | subroutine bar(this) 26 | type(typeA) :: this 27 | end subroutine 28 | end module 29 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20220221-submodule.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104630 2 | !! 3 | !! MODULE SUBROUTINE NOT ACCESSIBLE FROM SUBMODULE 4 | !! 5 | !! Host procedures should be accessible from submodules of the host. 6 | !! If the three program units are combined in a single file there is no error. 7 | !! 8 | !! $ gfortran gfortran-20220221-{module,submodule,main}.f90 9 | !! /usr/bin/ld: /tmp/ccrtpWxQ.o: in function `__moda_MOD_foo': 10 | !! gfortran-20220221-submodule.f90:(.text+0x17): undefined reference to `__moda_MOD_bar' 11 | !! collect2: error: ld returned 1 exit status 12 | 13 | submodule(modA) foo_impl 14 | contains 15 | module subroutine foo(this) 16 | class(typeA) :: this 17 | call bar(this) ! a module subroutine in the host module 18 | end subroutine 19 | end submodule 20 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20230513.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109846 2 | !! Fixed in 13.2.0 3 | !! 4 | !! REJECTS VALID CODE 5 | !! 6 | !! The following example is rejected by gfortran (13.1 and 12.2, and likely 7 | !! earlier). 8 | !! 9 | !! $ gfortran gfortran-20230513.f90 10 | !! gfortran-20230513.f90:17:11: 11 | !! 12 | !! 17 | call sub(plist%sublist()) 13 | !! | 1 14 | !! Error: 'sublist' in variable definition context (actual argument to 15 | !! INTENT = OUT/INOUT) at (1) is not a variable 16 | !! 17 | !! The source of the error appears to be sublist returning a polymorphic 18 | !! pointer. If it is modified to return a non-polymorphic pointer it 19 | !! compiles without error. Alternatively, if the dummy argument is changed 20 | !! to intent(in), it also compiles without error. 21 | !! 22 | !! See Sec 9.2, C902 (2018) and 6.2 C602 (2008) 23 | !! 24 | 25 | module foo 26 | type :: parameter_list 27 | contains 28 | procedure :: sublist 29 | end type 30 | contains 31 | function sublist(this) result(slist) 32 | class(parameter_list), intent(inout) :: this 33 | class(parameter_list), pointer :: slist 34 | allocate(slist) 35 | end function 36 | end module 37 | 38 | program example 39 | use foo 40 | type(parameter_list) :: plist 41 | call sub(plist%sublist()) 42 | contains 43 | subroutine sub(plist) 44 | type(parameter_list), intent(inout) :: plist 45 | end subroutine 46 | end program 47 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20230529.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110033 2 | !! 3 | !! REJECTS VALID CODE 4 | !! 5 | !! The following example has an ASSOCIATE construct with coarray selector. 6 | !! According to 11.1.3.3 par 2 (f2018), the corresponding associate name Y 7 | !! should be recognized as being a coarray, however gfortran 13.1 rejects 8 | !! this valid code: 9 | !! 10 | !! $ gfortran -fcoarray=lib gfortran-20230529.f90 11 | !! gfortran-20230529.f90:18:4: 12 | !! 13 | !! 14 | y[1] = 1.0 14 | !! | 1 15 | !! Error: Coarray designator at (1) but 'y' is not a coarray 16 | !! 17 | 18 | real :: x[*] 19 | associate (y => x) 20 | y[1] = 1.0 21 | end associate 22 | end 23 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20230612.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110224 2 | !! Fixed in 14.1.0 3 | !! 4 | !! VALID CODE REJECTED 5 | !! 6 | !! According to 9.2 of the F18 standard, the function reference x%VAR_PTR() 7 | !! is a variable and can appear in variable definition contexts, in particular 8 | !! as the selector in an associate construct (11.1.3.1, C1101) 9 | !! 10 | !! $ gfortran --version 11 | !! GNU Fortran (GCC) 13.1.0 12 | !! 13 | !! $ gfortran gfortran-20230612.f90 14 | !! gfortran-20230612.f90:18:4: 15 | !! 16 | !! 18 | var = 1.0 17 | !! | 1 18 | !! Error: 'var' at (1) associated to expression cannot be used in a variable definition context (assignment) 19 | !! 20 | 21 | module mod 22 | type :: foo 23 | real, pointer :: var 24 | contains 25 | procedure :: var_ptr 26 | end type 27 | contains 28 | function var_ptr(this) result(ref) 29 | class(foo) :: this 30 | real, pointer :: ref 31 | ref => this%var 32 | end function 33 | end module 34 | program main 35 | use mod 36 | type(foo) :: x 37 | associate (var => x%var_ptr()) 38 | var = 1.0 39 | end associate 40 | x%var_ptr() = 2.0 41 | end program 42 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20231211.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112964 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! $ gfortran --version 6 | !! GNU Fortran (GCC) 13.2.0 7 | !! 8 | !! $ gfortran gfortran-20231211.f90 9 | !! gfortran-20231211.f90:10:20: 10 | !! 11 | !! 24 | call foo(x(n)) 12 | !! | 1 13 | !! internal compiler error: Segmentation fault 14 | 15 | call foo([1,2]) 16 | contains 17 | recursive subroutine foo(x) 18 | class(*), intent(in) :: x(..) 19 | integer :: n 20 | select rank (x) 21 | rank (0) 22 | rank (1) 23 | do n = 1, size(x,1) 24 | call foo(x(n)) 25 | end do 26 | end select 27 | end subroutine 28 | end 29 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20250401.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119994 2 | !! 3 | !! VALID CODE REJECTED 4 | !! 5 | !! $ gfortran -c gfortran-20250401.f90 6 | !! gfortran-20250401.f90:35:21: 7 | !! 8 | !! 35 | real :: array2(this%n) 9 | !! | 1 10 | !! Error: Dummy argument ‘this’ at (1) cannot be INTENT(OUT) 11 | !! gfortran-20250401.f90:30:21: 12 | !! 13 | !! 30 | real :: array1(this%n) 14 | !! | 1 15 | !! Error: Dummy argument ‘this’ at (1) cannot be INTENT(OUT) 16 | !! 17 | !! In both cases, THIS%N is an object designator with a base object (THIS) 18 | !! that is made accessible by host association (2018: 10.1.11 par 2, item 4) 19 | !! and is thus a restricted expression and a valid specification expression. 20 | !! 21 | 22 | module foo 23 | 24 | type :: bar 25 | integer :: n 26 | end type 27 | 28 | contains 29 | 30 | subroutine init(this, n) 31 | type(bar), intent(out) :: this 32 | integer, intent(in) :: n 33 | this%n = n 34 | block 35 | real :: array1(this%n) 36 | end block 37 | call sub 38 | contains 39 | subroutine sub 40 | real :: array2(this%n) 41 | end subroutine 42 | end subroutine 43 | 44 | end module 45 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20250428.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119986 2 | !! Fixed in gfortran 15.1.1 (20250605) 3 | !! 4 | !! INCORRECT RESULTS 5 | !! 6 | !! The correct real and imaginary part references of a complex array 7 | !! are not being passed to the subroutine. 8 | !! 9 | 10 | program main 11 | type :: my_type 12 | complex, allocatable :: phi(:) 13 | end type 14 | integer :: j 15 | type(my_type) :: x 16 | x%phi = [(cmplx(j,-j),j=1,4)] 17 | call fubar(x%phi%re, x%phi%im) 18 | contains 19 | subroutine fubar(u, v) 20 | real, intent(in) :: u(:), v(:) 21 | if (any(u /= [1,2,3,4])) stop 1 22 | if (any(v /= -[1,2,3,4])) stop 2 23 | !print *, 'phi%re:', u 24 | !print *, 'phi%im:', v 25 | end subroutine 26 | end program 27 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-20250605.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119986 2 | !! Fixed in gfortran 15.1.1 (20250605) 3 | !! 4 | !! INCORRECT RESULTS 5 | !! 6 | !! The gfortran 15.1.0 compiler produces incorrect results for test1 and test3 7 | !! but correct results for test2. 8 | !! 9 | 10 | type :: foo 11 | complex :: z(3) 12 | end type 13 | 14 | call test1 15 | call test2 16 | call test3 17 | 18 | contains 19 | 20 | subroutine test1 21 | type(foo) :: a 22 | a%z%re = -1 23 | call bar(a%z%re) 24 | if (any(a%z%re /= [1,2,3])) stop 1 25 | a%z%im = -1 26 | call bar(a%z%im) 27 | if (any(a%z%im /= [1,2,3])) stop 2 28 | end subroutine 29 | 30 | subroutine test2 31 | type(foo) :: a 32 | a%z%re = -1 33 | associate (z => a%z) 34 | call bar(z%re) 35 | end associate 36 | if (any(a%z%re /= [1,2,3])) stop 3 37 | a%z%im = -1 38 | associate (z => a%z) 39 | call bar(z%im) 40 | end associate 41 | if (any(a%z%im /= [1,2,3])) stop 4 42 | end subroutine 43 | 44 | subroutine test3 45 | type(foo) :: a 46 | a%z%re = -1 47 | associate (z_re => a%z%re) 48 | call bar(z_re) 49 | end associate 50 | if (any(a%z%re /= [1,2,3])) stop 5 51 | a%z%im = -1 52 | associate (z_im => a%z%im) 53 | call bar(z_im) 54 | end associate 55 | if (any(a%z%im /= [1,2,3])) stop 6 56 | end subroutine 57 | 58 | subroutine bar(x) 59 | real, intent(inout) :: x(:) 60 | x = [1,2,3] 61 | end subroutine 62 | 63 | end 64 | -------------------------------------------------------------------------------- /gfortran-bugs/gfortran-bug-20110528.f90: -------------------------------------------------------------------------------- 1 | !! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213 2 | 3 | program main 4 | 5 | type :: S 6 | integer :: n 7 | end type 8 | type(S) :: Sobj 9 | 10 | type, extends(S) :: S2 11 | integer :: m 12 | end type 13 | type(S2) :: S2obj 14 | 15 | type :: T 16 | class(S), allocatable :: x 17 | end type 18 | 19 | Sobj = S(1) 20 | call pass_it (T(Sobj)) 21 | 22 | S2obj = S2(1,2) 23 | call pass_it (T(S2obj)) 24 | 25 | contains 26 | 27 | subroutine pass_it (foo) 28 | type(T), intent(in) :: foo 29 | end subroutine 30 | 31 | end program 32 | -------------------------------------------------------------------------------- /ibm-bugs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake") 4 | include(testing) 5 | 6 | #set(CMAKE_Fortran_FLAGS "" CACHE STRING "Fortran Compiler") 7 | 8 | project(ibm-bugs Fortran) 9 | 10 | set(CMAKE_Fortran_COMPILER xlf2008) # I don't know of a better way ... 11 | set(CMAKE_Fortran_FLAGS "") # CMake sets this to something, fools! 12 | 13 | add_compiler_test(SOURCES ibm-20180301a.f90 COMPILE_ONLY) 14 | add_compiler_test(SOURCES ibm-20180301b.f90 COMPILE_ONLY) 15 | add_compiler_test(SOURCES ibm-20180301c.F90 COMPILE_ONLY 16 | COMPILE_FLAGS "-WF,-qnotrigraph") 17 | add_compiler_test(SOURCES ibm-20180306a.f90 RUN_ONLY) 18 | add_compiler_test(SOURCES ibm-20180306b.f90 RUN_ONLY) 19 | add_compiler_test(SOURCES ibm-20180703.f90 COMPILE_ONLY) 20 | add_compiler_test(SOURCES ibm-20181201.f90 RUN_ONLY COMPILE_FLAGS "-g") 21 | add_compiler_test(SOURCES ibm-20181203a.f90 COMPILE_ONLY) 22 | add_compiler_test(SOURCES ibm-20181203b.f90 COMPILE_ONLY) 23 | add_compiler_test(SOURCES ibm-20181203c.f90 COMPILE_ONLY) 24 | add_compiler_test(SOURCES ibm-20181203d.f90 COMPILE_ONLY) 25 | -------------------------------------------------------------------------------- /ibm-bugs/ibm-20180301a.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! FUNCTION RESULT NOT RECOGNIZED TO HAVE BEEN SET 3 | !! 4 | !! Update: Now working in 16.1.1.2 5 | !! 6 | !! The call to the intrinsic function C_F_POINTER sets the value of the 7 | !! function result but the xlf compiler fails to recognize this and gives 8 | !! a spurious compilation error 9 | !! 10 | !! This is from https://github.com/nncarlson/petaca/blob/master/src/yajl_fort.F90 11 | !! 12 | !! $ xlf -qversion 13 | !! IBM XL Fortran for Linux, V15.1.6 (Community Edition) 14 | !! Version: 15.01.0006.0001 15 | !! 16 | !! $ xlf2008 -c bug.f90 17 | !! "bug.f90", 1513-006 (E) FUNCTION or ENTRY result is not set in the program unit. 18 | !! ** f_string_pointer_aux === End of Compilation 1 === 19 | !! 1501-510 Compilation successful for file bug.f90. 20 | 21 | function f_string_pointer_aux(cptr, len) result(fptr) 22 | use,intrinsic :: iso_c_binding 23 | type(c_ptr), intent(in) :: cptr 24 | integer(c_size_t), intent(in) :: len 25 | character(len,kind=c_char), pointer :: fptr 26 | call c_f_pointer(cptr, fptr) 27 | end function 28 | -------------------------------------------------------------------------------- /ibm-bugs/ibm-20180301b.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! INTERNAL COMPILER ERROR 3 | !! 4 | !! Update: Now working in 16.1.1.2 5 | !! 6 | !! This is a unit test from https://github.com/nncarlson/petaca stripped 7 | !! down to the bare minimum. The ICE goes away if anything else is removed. 8 | !! 9 | !! $ xlf2008 ibm-20180301b.f90 10 | !! /projects/opt/ppc64le/ibm/xlf-15.1.6/xlf/15.1.6/bin/.orig/xlf2008: 1501-230 (S) Internal compiler error; please contact your Service Representative. For more information visit: 11 | !! http://www.ibm.com/support/docview.wss?uid=swg21110810 12 | !! 1501-511 Compilation failed for file ibm-20180301b.f90. 13 | !! 14 | 15 | program test_any_scalar_type 16 | 17 | !call test_derived_type_value 18 | !call test_assignment 19 | !call test_shallow_assignment 20 | 21 | contains 22 | 23 | subroutine test_derived_type_value 24 | class(*), allocatable :: val 25 | type point 26 | !real x, y 27 | end type 28 | select type (val) 29 | type is (point) 30 | end select 31 | end subroutine 32 | 33 | subroutine test_assignment 34 | class(*), allocatable :: val 35 | type point 36 | !real x, y 37 | end type 38 | select type (val) 39 | type is (point) 40 | end select 41 | end subroutine 42 | 43 | subroutine test_shallow_assignment 44 | type box 45 | !integer, pointer :: n => null() 46 | end type 47 | !type(box) :: b 48 | end subroutine 49 | 50 | end program 51 | -------------------------------------------------------------------------------- /ibm-bugs/ibm-20180301c.F90: -------------------------------------------------------------------------------- 1 | !! 2 | !! SOURCE CORRUPTED BY PREPROCESSOR 3 | !! 4 | !! For some reason the XLF preprocessor is corrupting the valid Fortran 5 | !! string constant '???' in the following example, leading to a spurious 6 | !! compiler error. Note the source file has the suffix '.F90'. The 7 | !! preprocessor should not be modifying the source at all. 8 | !! 9 | !! Update: This is apparently by design as a C preprocessor: the ??' is 10 | !! a trigraph that stands for ^. Solution is to use -WF,-qnotrigraph to 11 | !! avoid expanding trigraphs. While I'll accept it makes sense as a C 12 | !! preprocess behavior, I think it is bad form for it to be behaving 13 | !! this way by default in the context of Fortran. 14 | !! 15 | !! This is from https://github.com/nncarlson/petaca/blob/master/src/parameter_entry_class.F90 16 | !! 17 | !! $ xlf ibm-20180301c.F90 18 | !! "ibm-20180301c.F90", line 14.0: 1515-010 (S) String is missing a closing delimiter. Closing delimiter assumed at end of line. 19 | !! ** _main === End of Compilation 1 === 20 | !! 1501-511 Compilation failed for file ibm-20180301c.F90. 21 | 22 | print *, '???' 23 | end 24 | -------------------------------------------------------------------------------- /ibm-bugs/ibm-20180306a.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! Update: bug persists in 16.1.1.2 3 | !! 4 | !! The following example passes a non-contiguous character substring 5 | !! array to an assumed-size CHARACTER(LEN=1) array dummy. This should 6 | !! result in a contiguous copy of the actual argument being passed to 7 | !! the subroutine. The xlf 15.1.6 compiler is not doing this. The 8 | !! Intel, NAG, and GFortran compilers all do the correct thing here. 9 | !! 10 | !! This is from https://github.com/nncarlson/petaca/blob/master/src/secure_hash/secure_hash_class.F90 11 | !! 12 | !! Expected result: foba 13 | !! IBM result: foob 14 | !! 15 | 16 | program main 17 | implicit none 18 | character(3) :: string_array(2) = ['foo', 'bar'] 19 | call sub1(string_array(:)(1:2)) 20 | contains 21 | subroutine sub1(data) 22 | character(*), intent(in) :: data(:) 23 | call sub2(data, len(data)*size(data)) 24 | end subroutine 25 | subroutine sub2(data, len) 26 | character, intent(in) :: data(*) ! FORCES A 27 | integer, intent(in) :: len 28 | integer :: i 29 | print *, (data(i), i=1,len) 30 | if (any(data(:len) /= ['f','o','b','a'])) stop 1 31 | end subroutine 32 | end 33 | -------------------------------------------------------------------------------- /ibm-bugs/ibm-20180703.f90: -------------------------------------------------------------------------------- 1 | !! VALID SPECIFICATION FUNCTION NOT RECOGNIZED AS SUCH 2 | !! 3 | !! Update: Now working in 16.1.1.2 4 | !! 5 | !! $ xlf2008 -qversion 6 | !! IBM XL Fortran for Linux, V16.1.1 (Beta 2) 7 | !! Version: 16.01.0001.0000 8 | !! 9 | !! $ xlf2008 -c ibm-20180703.f90 10 | !! "ibm-20180703.f90", line 30.19: 1514-433 (S) A non-intrinsic procedure 11 | !! referenced in a specification expression must be a specification function. 12 | !! ** example === End of Compilation 1 === 13 | !! 1501-511 Compilation failed for file ibm-20180703.f90. 14 | !! 15 | !! This is a spurious error. 16 | !! 17 | !! According to 7.1.11 par 5 (F2008) output_length is a specification function. 18 | !! It is pure, not a standard intrinsic, not internal, and has no procedure 19 | !! argument. Furthermore, output_length(n) is valid specification expression, 20 | !! as the non-optional, intent(in) dummy argument is a restricted expression 21 | !! by par 2 (11) and par 2 (2). 22 | !! 23 | !! This example arises from string_utilities.F90 of Truchas. 24 | !! 25 | 26 | module example 27 | 28 | contains 29 | 30 | function i_to_c(n) result(s) 31 | integer, intent(in) :: n 32 | character(len=output_length(n)) :: s 33 | s = '' 34 | end function 35 | 36 | pure integer function output_length(n) 37 | integer, intent(in) :: n 38 | output_length = 1 39 | end function 40 | 41 | end module 42 | -------------------------------------------------------------------------------- /ibm-bugs/ibm-20181203c.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! REJECTS VALID CODE 3 | !! 4 | !! Update: Now working in 16.1.1.2 5 | !! 6 | !! The XL Fortran 16.1.1-rc3 compiler rejects the following code with the 7 | !! error 8 | !! 9 | !! $ xlf ibm-20181203c.f90 10 | !! "ibm-20181203c.f90", line 26.15: 1514-433 (S) A non-intrinsic procedure referenced in a specification expression must be a specification function. 11 | !! ** foo === End of Compilation 1 === 12 | !! 1501-511 Compilation failed for file ibm-20181203c.f90. 13 | !! 14 | !! The non-intrinsic procedure referenced is OUTPUT_LENGTH, and it is very 15 | !! clearly a specification function: 16 | !! 17 | !! F2008: 7.1.11 5) A function is a specification function if it is a pure 18 | !! function, is not a standard intrinsic function, is not an internal function, is not 19 | !! a statement function, and does not have a dummy procedure argument. 20 | !! 21 | !! Moreover OUTPUT_LENGTH(N) is a valid specification expression. 22 | !! 23 | 24 | module foo 25 | contains 26 | pure function i_to_c(n) result(output) 27 | integer, intent(in) :: n 28 | character(output_length(n)) :: output 29 | output = 'foo' 30 | end function 31 | pure integer function output_length(n) 32 | integer, intent(in) :: n 33 | output_length = 3 34 | end function 35 | end module 36 | -------------------------------------------------------------------------------- /ibm-bugs/ibm-20181203d.f90: -------------------------------------------------------------------------------- 1 | !! INTERNAL COMPILER ERROR 2 | !! 3 | !! Update: Now working in 16.1.1.2 4 | !! 5 | !! Using xlf 16.1.1-rc3 on power9 6 | !! 7 | !! $ xlf2008 ibm-20181203d.f90 8 | !! ** map_any_type === End of Compilation 1 === 9 | !! ** parameter_list_type === End of Compilation 2 === 10 | !! ** scalar_func_factories === End of Compilation 3 === 11 | !! ** phase_property_table_factory === End of Compilation 4 === 12 | !! xlf2008: 1501-230 (S) Internal compiler error; please contact your Service Representative. For more information visit: 13 | !! 14 | 15 | module map_any_type 16 | private 17 | type :: list_item 18 | class(*), allocatable :: value 19 | end type 20 | type, public :: map_any 21 | type(list_item), pointer :: first => null() 22 | end type 23 | end module 24 | 25 | module parameter_list_type 26 | use map_any_type 27 | type :: parameter_list 28 | type(map_any) :: params = map_any() 29 | end type 30 | end module 31 | 32 | module scalar_func_factories 33 | contains 34 | subroutine alloc_scalar_func(params) 35 | use parameter_list_type 36 | type(parameter_list) :: params 37 | end subroutine 38 | end module 39 | 40 | module phase_property_table_factory 41 | use scalar_func_factories 42 | use parameter_list_type 43 | contains 44 | subroutine init(params) 45 | type(parameter_list) :: params 46 | end subroutine 47 | end module 48 | 49 | ! INTERNAL COMPILER ERROR ON THIS PROGRAM UNIT 50 | program test_init_phase_property_table 51 | use phase_property_table_factory, only: init 52 | end program 53 | -------------------------------------------------------------------------------- /intel-bugs/intel-20121006b-main.f90: -------------------------------------------------------------------------------- 1 | program main 2 | use mod 3 | use,intrinsic :: iso_c_binding, only: c_long_long 4 | call sub (int(1_c_long_long)) 5 | !n = 1_c_long_long 6 | !call sub (n) 7 | end program 8 | -------------------------------------------------------------------------------- /intel-bugs/intel-20121006b.f90: -------------------------------------------------------------------------------- 1 | !Issue number DPD200237121 2 | !! 3 | !! INTERNAL COMPILER ERROR -- INTEL 13.0.0 4 | !! 5 | !! % ifort --version 6 | !! ifort (IFORT) 13.0.0 20120731 7 | !! 8 | !! % ifort -c intel-bug-20121006b-1.f90 intel-bug-20121006b-2.f90 9 | !! 04010002_1529 10 | !! 11 | !! intel-bug-20121006b-2.f90(4): catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error. 12 | !! compilation aborted for intel-bug-20121006b-2.f90 (code 1) 13 | !! 14 | 15 | module mod 16 | contains 17 | subroutine sub (value) 18 | class(*), intent(in) :: value 19 | end subroutine 20 | end module 21 | 22 | ! PUT THIS IN A SEPARATE SOURCE FILE 23 | !program main 24 | ! use mod 25 | ! use,intrinsic :: iso_c_binding, only: c_long_long 26 | ! call sub (int(1_c_long_long)) 27 | !end program 28 | -------------------------------------------------------------------------------- /intel-bugs/intel-20121007b.f90: -------------------------------------------------------------------------------- 1 | !Issue number DPD200237182 2 | !! FINALIZATION PERFORMED FOR A NON-FINALIZABLE DATA ENTITY 3 | !! 4 | !! In the following example a function returns a pointer to finalizable 5 | !! derived type. The result of the function reference, being a pointer, 6 | !! is not finalizable however (1.3.76 and 4.5.6.2 item 1). Yet this is 7 | !! precisely what the Intel 13.0.0 compiler does when executing the 8 | !! pointer assignment "obj => object_ptr()" -- the target is finalized 9 | !! when it should not be. This is evidenced by having the final 10 | !! subroutine write a message. 11 | !! 12 | !! % ifort --version 13 | !! ifort (IFORT) 13.0.0 20120731 14 | !! 15 | !! % ifort intel-bug-20121007b.f90 16 | !! % ./a.out 17 | !! FINALIZER CALLED 18 | !! FINALIZER SHOULD NOT CALLED BEFORE THIS LINE 19 | !! 20 | 21 | module mod 22 | 23 | type :: object 24 | contains 25 | final :: delete_object 26 | end type 27 | 28 | contains 29 | 30 | subroutine delete_object (this) 31 | type(object), intent(inout) :: this 32 | print *, 'FINALIZER CALLED' 33 | end subroutine 34 | 35 | !! Any function returning a TYPE(OBJECT) POINTER will do. 36 | function object_ptr () result (ptr) 37 | type(object), pointer :: ptr 38 | allocate(ptr) 39 | end function 40 | 41 | end module 42 | 43 | program main 44 | use mod 45 | type(object), pointer :: obj 46 | obj => object_ptr() 47 | print *, 'FINALIZER SHOULD NOT CALLED BEFORE THIS LINE' 48 | end program 49 | -------------------------------------------------------------------------------- /intel-bugs/intel-20130802.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! The Intel compiler is stumbling over the type-is statement 3 | !! in the following example when it shouldn't be. 4 | !! 5 | !! % ifort --version 6 | !! ifort (IFORT) 13.1.2 20130514 7 | !! 8 | !! % ifort intel-bug-20130802.f90 9 | !! intel-bug-20130802.f90(21): error #6402: prPromoteSym : Illegal KIND & CLASS mix [KIND] 10 | !! type is (integer(kind(val))) 11 | !! -------------------^ 12 | !! compilation aborted for intel-bug-20130802.f90 (code 1) 13 | !! 14 | 15 | subroutine fubar (cs, val) 16 | 17 | class(*) :: cs 18 | integer :: val 19 | 20 | select type (cs) 21 | type is (integer(kind(val))) 22 | end select 23 | 24 | end subroutine 25 | -------------------------------------------------------------------------------- /intel-bugs/intel-20130802a.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! The compiler is stumbling over the type-is statement in the example below. 3 | !! For some reason it does not see int32 (an intrinsic module named constant) 4 | !! as a compile time constant (it is). 5 | !! 6 | !! If the subroutine is made an external procedure rather than a module 7 | !! procedure, there is no compilation error. 8 | !! 9 | !! If the intrinsic module is used by the module instead of the procedure, 10 | !! the compilation error also goes away. 11 | !! 12 | !! % ifort --version 13 | !! ifort (IFORT) 13.1.2 20130514 14 | !! 15 | !! % ifort intel-bug-20130802a.f90 16 | !! intel-bug-20130802a.f90(34): error #6683: A kind type parameter must be a compile-time constant. [INT32] 17 | !! type is (integer(int32)) 18 | !! ---------------------^ 19 | !! compilation aborted for intel-bug-20130802a.f90 (code 1) 20 | !! 21 | 22 | module fubar_module 23 | 24 | ! put it here and everything is okay 25 | !use,intrinsic :: iso_fortran_env, only: int32 26 | 27 | contains 28 | 29 | subroutine fubar (cs) 30 | ! put it here and the compiler stumbles 31 | use,intrinsic :: iso_fortran_env, only: int32 32 | class(*) :: cs 33 | select type (cs) 34 | type is (integer(int32)) 35 | end select 36 | end subroutine 37 | 38 | end module 39 | -------------------------------------------------------------------------------- /intel-bugs/intel-20131030.f90: -------------------------------------------------------------------------------- 1 | !Issue number DPD200249493 2 | !! 3 | !! COMPILER GENERATES INCORRECT CODE 4 | !! 5 | !! In the following example, a derived-type scalar pointer P is allocated and 6 | !! then deallocated. At that point, ASSOCIATED(P) should return FALSE but it 7 | !! returns TRUE. Key to the error seems to be that the pointer is a dummy 8 | !! argument and that the derived type contains an allocatable CLASS(*) component. 9 | !! 10 | !! $ ifort --version 11 | !! ifort (IFORT) 14.0.0 20130728 12 | !! 13 | !! $ ifort intel-bug-20131030.f90 14 | !! $ ./a.out 15 | !! associated(p) = T (should be FALSE) 16 | !! 17 | 18 | module foo_mod 19 | type, public :: foo 20 | class(*), allocatable :: value 21 | end type 22 | contains 23 | subroutine sub (p) 24 | type(foo), pointer :: p 25 | allocate(p) 26 | deallocate(p) 27 | print *, 'associated(p) =', associated(p), '(should be FALSE)' 28 | if (associated(p)) stop 1 29 | end subroutine 30 | end module 31 | 32 | program main 33 | use foo_mod 34 | type(foo), pointer :: p 35 | call sub (p) 36 | end program 37 | 38 | -------------------------------------------------------------------------------- /intel-bugs/intel-20140420.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! INTERNAL COMPILER ERROR 3 | !! 4 | !! % ifort --version 5 | !! ifort (IFORT) 14.0.2 20140120 6 | !! 7 | !! % ifort -c -standard-semantics foo.f90 8 | !! 010101_13220 9 | !! 10 | !! catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error. 11 | !! 12 | 13 | subroutine fubar (array, mask) 14 | integer, allocatable :: array(:) 15 | logical :: mask(:) 16 | array = merge(1, array, mask) 17 | end subroutine 18 | -------------------------------------------------------------------------------- /intel-bugs/intel-20140610.f90: -------------------------------------------------------------------------------- 1 | !Issue number DPD200357444 2 | !! 3 | !! ELEMENTAL FUNCTION RETURNS INCORRECT RESULT 4 | !! 5 | !! In the following example the elemental function returns the 6 | !! incorrect result when used with a scalar argument 7 | !! 8 | !! % ifort --version 9 | !! ifort (IFORT) 14.0.2 20140120 10 | !! 11 | !! % ifort intel-bug-20140610.f90 12 | !! % ./a.out 13 | !! XXXXX (expect "XXXXX") 14 | !! fubar (expect "XXXXX") <== INCORRECT RESULT 15 | !! XX (expect "XX") 16 | !! 17 | 18 | module string_utilities 19 | contains 20 | 21 | function raise_case (s) result (ucs) 22 | character(*), intent(in) :: s 23 | character(len(s)) :: ucs 24 | ucs = repeat('X',len(s)) ! ignore S and just assign fixed string 25 | end function 26 | 27 | elemental function elem_raise_case (s) result (ucs) 28 | character(*), intent(in) :: s 29 | character(len(s)) :: ucs 30 | ucs = repeat('X',len(s)) ! ignore S and just assign fixed string 31 | end function 32 | 33 | function string () 34 | character(:), allocatable :: string 35 | string = 'fubar' 36 | end function 37 | end module 38 | 39 | program example 40 | use string_utilities 41 | print *, raise_case(string()), ' (expect "XXXXX")' ! CORRECT RESULT 42 | print *, elem_raise_case(string()), ' (expect "XXXXX")' ! GIVES WRONG RESULT 43 | print *, elem_raise_case(['a','z']), ' (expect "XX")' ! BUT THIS IS CORRECT 44 | if (raise_case(string()) /= 'XXXXX') stop 1 45 | if (elem_raise_case(string()) /= 'XXXXX') stop 2 46 | if (any(elem_raise_case(['a','z']) /= 'X')) stop 3 47 | end program 48 | -------------------------------------------------------------------------------- /intel-bugs/intel-20140616.f90: -------------------------------------------------------------------------------- 1 | !Issue number DPD200357656 2 | !! 3 | !! INCORRECT RESULTS 4 | !! 5 | !! The following example produces incorrect results. 6 | !! 7 | !! % ifort --version 8 | !! ifort (IFORT) 14.0.2 20140120 9 | !! 10 | !! % ifort intel-bug-20140616.f90 11 | !! % ./a.out 12 | !! expect 1 2 3 4: 1 2 3 4 13 | !! expect 1 3: 538976288 538976288 14 | !! expect 2 4: 538976288 538976288 15 | !! expect 1 2: 1 2 16 | !! expect 3 4: 1 2 17 | !! 18 | 19 | program main 20 | 21 | class(*), allocatable, target :: array(:) 22 | class(*), pointer :: ptr(:,:) 23 | 24 | allocate(array, source=[1,2,3,4]) 25 | 26 | ptr(1:2,1:2) => array 27 | 28 | select type (ptr) 29 | type is (integer) 30 | print *, 'expect 1 2 3 4:', ptr 31 | print *, 'expect 1 3:', ptr(1,:) 32 | print *, 'expect 2 4:', ptr(2,:) 33 | print *, 'expect 1 2:', ptr(:,1) 34 | print *, 'expect 3 4:', ptr(:,2) 35 | if (all(ptr(1,:) == [1,3]) .and. all(ptr(2,:) == [2,4]) .and. & 36 | all(ptr(:,1) == [1,2]) .and. all(ptr(:,2) == [3,4])) then 37 | print *, 'pass' 38 | else 39 | print *, 'fail' 40 | end if 41 | end select 42 | 43 | end program 44 | -------------------------------------------------------------------------------- /intel-bugs/intel-20140617.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! POINTER ASSIGNMENT NOT DEFINING DEFERRED LENGTH PARAMETER 3 | !! 4 | !! In the following example, the second pointer assignment involving 5 | !! rank remapping is not properly defining the deferred length parameter 6 | !! of the pointer object (see F2008 5.3.14 #3). Key to the error is 7 | !! that the target is a deferred-length allocatable 8 | !! 9 | !! % ifort --version 10 | !! ifort (IFORT) 14.0.2 20140120 11 | !! 12 | !! % ifort intel-bug-20140617.f90 13 | !! % ./a.out 14 | !! len= 3 (expect 3 ) 15 | !! len= 0 (expect 3 ) <== THIS IS WRONG 16 | !! 17 | 18 | program main 19 | character(:), allocatable, target :: array(:) 20 | character(:), pointer :: ptr1(:), ptr2(:,:) 21 | allocate(array(1), source=['foo']) 22 | ptr1 => array ! THIS WORKS 23 | print *, 'len=', len(ptr1), ' (expect', len(array), ')' 24 | ptr2(1:1,1:1) => array ! THIS DOES NOT WORK 25 | print *, 'len=', len(ptr2), ' (expect', len(array), ')' 26 | if (len(ptr2) == 3) then 27 | print *, 'pass' 28 | else 29 | print *, 'fail' 30 | end if 31 | end program 32 | -------------------------------------------------------------------------------- /intel-bugs/intel-20140618a.f90: -------------------------------------------------------------------------------- 1 | !Issue number DPD200357693 2 | !! 3 | !! In the following example, an allocatable component of a variable is 4 | !! allocated and then deallocated, but the ALLOCATED intrinsic reports 5 | !! that the component is still allocated. It seems significant that 6 | !! the component is a derived type with a CLASS(*) allocatable component. 7 | !! 8 | !! % ifort --version 9 | !! ifort (IFORT) 14.0.2 20140120 10 | !! 11 | !! % ifort intel-bug-20140618a.f90 12 | !! % ./a.out 13 | !! T (expect F) 14 | !! 15 | 16 | program main 17 | 18 | type :: T1 19 | class(*), allocatable :: bar 20 | end type 21 | 22 | type :: T2 23 | type(T1), allocatable :: foo 24 | end type 25 | 26 | type(T2) :: x 27 | 28 | allocate(x%foo) 29 | deallocate(x%foo) 30 | if (allocated(x%foo)) then 31 | print *, 'fail' 32 | else 33 | print *, 'pass' 34 | end if 35 | !print '(a,l1,a)', 'alloc=', allocated(x%foo), ' (expect F)' ! GIVES THE WRONG RESULT 36 | 37 | end program 38 | -------------------------------------------------------------------------------- /intel-bugs/intel-20141014-main.f90: -------------------------------------------------------------------------------- 1 | program main 2 | use my_mod 3 | real(real64) :: vf(2,25) 4 | vf = 1.0_real64 5 | call use_count_with_dim (vf) 6 | end program 7 | -------------------------------------------------------------------------------- /intel-bugs/intel-20141014.f90: -------------------------------------------------------------------------------- 1 | !Issue number DPD200362104 2 | !! 3 | !! OPTIMIZER BUG 4 | !! 5 | !! The following example generates the wrong results when compiled with the -O 6 | !! flag, but correct results with -g instead of -O. The error seems to be 7 | !! associated with an intrinsic COUNT reference (with DIM argument) used as an 8 | !! actual argument. This error is new to version 15 -- it is not present in 9 | !! versions 13 or 14. The OS is Fedora 20 and CPU an Intel i7-4930MX. 10 | !! 11 | !! % ifort --version 12 | !! ifort (IFORT) 15.0.0 20140723 13 | !! 14 | !! % ifort -g intel-bug-20141014-file2.f90 intel-bug-20141014-file1.f90 15 | !! % ./a.out 16 | !! M=2 (expect M=2) <=== THIS IS OKAY 17 | !! 18 | !! % ifort -O intel-bug-20141014-file2.f90 intel-bug-20141014-file1.f90 19 | !! % ./a.out 20 | !! M=0 (expect M=2) <=== THIS IS WRONG 21 | !! 22 | 23 | module my_mod 24 | use,intrinsic :: iso_fortran_env, only: real64 25 | type some_type 26 | integer :: foo 27 | end type 28 | contains 29 | subroutine use_count_with_dim (vf) 30 | real(real64), intent(in) :: vf(:,:) 31 | type(some_type), allocatable :: unused(:) 32 | m = maxval(count(vf /= 0.0_real64, dim=1)) 33 | print '(a,i0,a)', 'M=', m, ' (expect 2)' 34 | end subroutine 35 | end module 36 | 37 | ! THIS MUST GO INTO A SEPARATE SOURCE FILE 38 | !program main 39 | ! use my_mod 40 | ! real(real64) :: vf(2,25) 41 | ! vf = 1.0_real64 42 | ! call use_count_with_dim (vf) 43 | !end program 44 | -------------------------------------------------------------------------------- /intel-bugs/intel-20171018.f90: -------------------------------------------------------------------------------- 1 | !! Compiler fails to correctly interpret type declaration with multiple components. 2 | !! 3 | !! $ ifort --version -c intel-bug-20171018.f90 4 | !! ifort (IFORT) 18.0.0 20170811 5 | !! 6 | !! $ ifort -c intel-bug-20171018.f90 7 | !! intel-bug-20171018.f90(20): error #6404: This name does not have a type, and must have an explicit type. [LAST] 8 | !! type(path_segment), pointer :: first => null(), last => null(), curr => null() 9 | !! ----------------------------------------------------^ 10 | !! intel-bug-20171018.f90(20): error #6404: This name does not have a type, and must have an explicit type. [FIRST] 11 | !! type(path_segment), pointer :: first => null(), last => null(), curr => null() 12 | !! -----------------------------------^ 13 | !! compilation aborted for intel-bug-20171018.f90 (code 1) 14 | 15 | module example 16 | 17 | implicit none 18 | 19 | type, public :: toolpath 20 | type(path_segment), pointer :: first => null(), last => null(), curr => null() 21 | end type 22 | 23 | type :: path_segment 24 | end type 25 | 26 | end module 27 | -------------------------------------------------------------------------------- /intel-bugs/intel-20171019.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! Unlimited polymorphic function result is wrong with the 18.0.0 3 | !! compiler when its dynamic type is character -- its length is 0. 4 | !! 5 | !! $ ifort --version 6 | !! ifort (IFORT) 18.0.0 20170811 7 | !! 8 | !! $ ifort intel-bug-20171019a.f90 9 | !! $ ./a.out 10 | !! "" (expect "fubar") <== WRONG 11 | !! 12 | !! This is a regression; versions 17 and earlier return the correct result 13 | 14 | program main 15 | character(5), target :: string = 'fubar' 16 | class(*), pointer :: p 17 | p => func() 18 | select type (p) 19 | type is (character(*)) 20 | write(*,'(3a)') 'p="', p, '" (expect "fubar")' 21 | end select 22 | contains 23 | function func() 24 | class(*), pointer :: func 25 | func => string 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /intel-bugs/intel-20171019a.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! Unlimited polymorphic function result is wrong with the 18.0.0 3 | !! compiler when its dynamic type is character -- its length is 0. 4 | !! 5 | !! $ ifort --version 6 | !! ifort (IFORT) 18.0.0 20170811 7 | !! 8 | !! $ ifort intel-bug-20171019a.f90 9 | !! $ ./a.out 10 | !! "" (expect "fubar") <== WRONG 11 | !! 12 | !! This is a regression; versions 17 and earlier return the correct result 13 | 14 | program main 15 | character(5), target :: string = 'fubar' 16 | class(*), pointer :: p 17 | p => func() 18 | select type (p) 19 | type is (character(*)) 20 | write(*,'(3a)') '"', p, '" (expect "fubar")' 21 | end select 22 | contains 23 | function func() 24 | class(*), pointer :: func 25 | func => string 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /intel-bugs/intel-20171023.f90: -------------------------------------------------------------------------------- 1 | !! The following example returns the INCORRECT results with version 2 | !! 18.0.0 20170811 of the Intel compiler: 3 | !! 4 | !! $ ifort intel-bug-20171023.f90 5 | !! $ ./a.out 6 | !! 1065353216 (expect 1) 7 | !! 8 | !! CORRECT results are obtained with versions 17.0.1 and 16.0.3, as well 9 | !! as the gfortran and NAG compilers. 10 | 11 | module any_scalar_type 12 | 13 | type any_scalar 14 | class(*), allocatable :: value 15 | end type 16 | 17 | contains 18 | 19 | function value_ptr(this) result(uptr) 20 | class(any_scalar), target, intent(in) :: this 21 | class(*), pointer :: uptr 22 | uptr => this%value 23 | end function 24 | 25 | end module 26 | 27 | 28 | program main 29 | 30 | use any_scalar_type 31 | 32 | type(any_scalar), target :: foo 33 | class(*), allocatable :: scalar 34 | class(*), pointer :: uptr 35 | 36 | type point; real x, y; end type 37 | allocate(scalar, source=point(1.0,2.0)) 38 | 39 | allocate(foo%value, source=1) 40 | uptr => value_ptr(foo) 41 | deallocate(scalar) 42 | allocate(scalar, source=uptr) ! should hold the value 1 43 | 44 | select type (scalar) 45 | type is (integer) 46 | if (scalar == 1) then 47 | print *, 'pass:', scalar, '(expect 1)' 48 | else 49 | print *, 'fail:', scalar, '(expect 1)' 50 | end if 51 | end select 52 | 53 | end program 54 | -------------------------------------------------------------------------------- /intel-bugs/intel-20171115.f90: -------------------------------------------------------------------------------- 1 | !! Compiler fails to correctly interpret type declaration with multiple components. 2 | !! This is a variation of intel-bug-20171018.f90 (fixed in 18.0.1) that makes 3 | !! TOOLPATH an extension of another type. This has the same problem. 4 | !! 5 | !! $ ifort --version intel-bug-20171115.f90 6 | !! ifort (IFORT) 18.0.1 20171018 7 | !! 8 | !! $ ifort -c intel-bug-20171115.f90 9 | !! intel-bug-20171115.f90(25): error #6404: This name does not have a type, and must have an explicit type. [LAST] 10 | !! type(path_segment), pointer :: first => null(), last => null(), curr => null() 11 | !! ----------------------------------------------------!! 12 | !! intel-bug-20171115.f90(25): error #6404: This name does not have a type, and must have an explicit type. [FIRST] 13 | !! type(path_segment), pointer :: first => null(), last => null(), curr => null() 14 | !! -----------------------------------!! 15 | !! compilation aborted for intel-bug-20171115.f90 (code 1) 16 | 17 | module example 18 | 19 | implicit none 20 | 21 | type, abstract :: path 22 | end type 23 | 24 | type, extends(path), public :: toolpath 25 | type(path_segment), pointer :: first => null(), last => null(), curr => null() 26 | end type 27 | 28 | type :: path_segment 29 | end type 30 | 31 | end module 32 | -------------------------------------------------------------------------------- /intel-bugs/intel-20171126.f90: -------------------------------------------------------------------------------- 1 | !! SRN 03140120: fixed in 19.0.4 2 | !! 3 | !! ICE on MERGE inside TYPE IS block 4 | !! 5 | !! ICE on 18.0.1, 17.0.1, 16.0.2. No ICE if val is an integer 6 | !! variable and not polymorphic. 7 | !! 8 | !! $ ifort --version 9 | !! ifort (IFORT) 18.0.1 20171018 10 | !! Copyright (C) 1985-2017 Intel Corporation. All rights reserved. 11 | !! 12 | !! $ ifort intel-20171126.f90 13 | !! intel-20171126.f90(5): catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error. 14 | !! compilation aborted for intel-20171126.f90 (code 1) 15 | !! 16 | 17 | class(*), allocatable :: val 18 | allocate(val, source=42) 19 | select type (val) 20 | type is (integer) 21 | print *, merge('pass', 'fail', val==42) 22 | end select 23 | end 24 | -------------------------------------------------------------------------------- /intel-bugs/intel-20180115.f90: -------------------------------------------------------------------------------- 1 | !! Support request 03209754: fixed in 19.0.4 2 | !! 3 | !! LENGTH PARAMETER NOT SET FOR POLYMORPHIC SELECT-TYPE SELECTOR 4 | !! 5 | !! In the following example a type bound function returning a pointer to an 6 | !! unlimited polymorphic variable is used as the selector in a SELECT TYPE 7 | !! construct. When the dynamic type is CHARACTER, the length type of the 8 | !! selector is not being set correctly. 9 | !! 10 | !! $ ifort --version 11 | !! ifort (IFORT) 18.0.1 20171018 12 | !! 13 | !! $ ifort intel-20180115.f90 14 | !! $ ./a.out 15 | !! 0 '' 16 | !! 17 | !! The correct output is 18 | !! 5 'fubar' 19 | !! 20 | 21 | module foo_type 22 | 23 | type :: foo 24 | class(*), pointer :: uptr => null() 25 | contains 26 | procedure :: return_uptr 27 | end type 28 | 29 | contains 30 | 31 | function return_uptr(this) result(uptr) 32 | class(foo) :: this 33 | class(*), pointer :: uptr 34 | uptr => this%uptr 35 | end function 36 | 37 | end module 38 | 39 | 40 | program main 41 | 42 | use foo_type 43 | type(foo) :: x 44 | 45 | allocate(x%uptr, source='fubar') 46 | 47 | select type (uptr => x%return_uptr()) 48 | type is (character(*)) 49 | write(*,'(i0,1x,"''",a,"''")') len(uptr), uptr ! EXPECT 5 'fubar' 50 | end select 51 | 52 | end program 53 | 54 | -------------------------------------------------------------------------------- /intel-bugs/intel-20180117.f90: -------------------------------------------------------------------------------- 1 | !! Support request 03212814: Fixed in 19.0.4 2 | !! 3 | !! Array bounds are not being set correctly in ALLOCATE with MOLD= 4 | !! 5 | !! Fortran 2008 standard, 6.7.1.2 item 6: "When an ALLOCATE statement is 6 | !! executed for an array with no allocate-shape-spec-list, the bounds of 7 | !! source-expr determine the bounds of the array." 8 | !! 9 | !! $ ifort --version 10 | !! ifort (IFORT) 18.0.1 20171018 11 | !! 12 | !! $ ifort intel-20180117.f90 13 | !! $ ./a.out 14 | !! 1 5 15 | !! 16 | !! The correct expected result is 17 | !! 5 9 18 | !! 19 | 20 | integer, pointer :: a(:), b(:) 21 | allocate(a(5:9)) 22 | allocate(b, mold=a) 23 | print '(i0,1x,i0)', lbound(b), ubound(b) ! EXPECT 5 9 24 | end 25 | -------------------------------------------------------------------------------- /intel-bugs/intel-20180222.f90: -------------------------------------------------------------------------------- 1 | !! The following example gives a spurious run time error at the sourced 2 | !! allocation statement when compiled with 17.0.6 (18.0.1 is okay): 3 | !! 4 | !! forrtl: severe (190): for allocate(source=), source needs to be allocated 5 | !! Image PC Routine Line Source 6 | !! a.out 000000000040464E Unknown Unknown Unknown 7 | !! a.out 0000000000402B91 MAIN__ 12 bug.f90 8 | !! 9 | !! The dummy argument X is associated with the value of the constructor 10 | !! expression EXTENDED(). There is no question here of X being allocated 11 | !! or not -- it is not allocatable. 12 | !! 13 | !! The error is specific to the case of polymorphic variables when the 14 | !! types contain no components. The error goes away if a dummy component 15 | !! is added to either the base class or the extended type. 16 | 17 | type, abstract :: base 18 | end type 19 | 20 | type, extends(base) :: extended 21 | !integer :: dummy = 1 22 | end type 23 | 24 | call foo(extended()) 25 | 26 | contains 27 | subroutine foo(x) 28 | class(base), intent(in) :: x 29 | class(base), allocatable :: y 30 | allocate(y, source=x) ! RUN TIME ERROR HERE 31 | end subroutine 32 | end 33 | -------------------------------------------------------------------------------- /intel-bugs/intel-20190901.f90: -------------------------------------------------------------------------------- 1 | !! Support request 04329123 2 | !! Still broken in 19.0.5 and 19.1.0 3 | !! 4 | !! REJECTS VALID CODE 5 | !! 6 | !! The Intel 18 compiler rejects the following code with this error: 7 | !! 8 | !! $ ifort -c intel-20190901.f90 9 | !! intel-20190901.f90(14): error #6437: A subroutine or function is calling itself recursively. [UPDATE_] 10 | !! if (same_type_as(this, other)) call this%update_(other) 11 | !! ---------------------------------------------^ 12 | !! 13 | !! However there are no recursive calls here whatsoever. The fact that 14 | !! update and update_ have the same interface is irrelevant. 15 | !! 16 | 17 | module example 18 | 19 | type, abstract :: base_class 20 | contains 21 | procedure, non_overridable :: update 22 | procedure(update), deferred :: update_ 23 | end type 24 | 25 | contains 26 | 27 | subroutine update(this, other) 28 | class(base_class), intent(inout) :: this 29 | class(base_class), intent(in) :: other 30 | if (same_type_as(this, other)) call this%update_(other) 31 | end subroutine 32 | 33 | end module 34 | -------------------------------------------------------------------------------- /intel-bugs/intel-20190903.f90: -------------------------------------------------------------------------------- 1 | !! Service Request Number: 04330341 2 | !! Still broken in 19.0.5 and 19.1.0 3 | !! 4 | !! INTERNAL COMPILER ERROR 5 | !! 6 | !! This is a regression in version 19. Works fine in versions 17 and 18. 7 | !! 8 | !! $ ifort --version 9 | !! ifort (IFORT) 19.0.4.243 20190416 10 | !! Copyright (C) 1985-2019 Intel Corporation. All rights reserved. 11 | !! 12 | !! $ ifort -c intel-20190903.f90 13 | !! intel-20190903.f90(22): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance. 14 | !! end module 15 | 16 | module fhypre 17 | use,intrinsic :: iso_c_binding, only: hypre_associated => c_associated 18 | private 19 | public :: hypre_associated 20 | end module 21 | 22 | module hypre_hybrid_type 23 | use fhypre 24 | end module 25 | 26 | -------------------------------------------------------------------------------- /intel-bugs/intel-20190909.f90: -------------------------------------------------------------------------------- 1 | !! Service Request Number: 04337903 2 | !! Fixed in 19.1.0. Still broken in 19.0.5 3 | !! 4 | !! DO CONCURRENT TYPE SPEC IGNORED IN MODULE PROCEDURE 5 | !! 6 | !! Declaration of the type of the index variable in the DO CONCURRENT construct 7 | !! works correctly when the construct is in a loose procedure like external_sub 8 | !! below, but not in a module procedure like module_sub, where the compiler 9 | !! incorrectly complains that J has no type. This occurs with Intel 18 and 19. 10 | !! 11 | !! $ ifort --version 12 | !! ifort (IFORT) 19.0.4.243 20190416 13 | !! 14 | !! $ ifort -c intel-20190909.f90 15 | !! intel-20190909.f90(33): error #6404: This name does not have a type, and must have an explicit type. [J] 16 | !! array2(j) = 0 ! ERROR HERE -- J HAS NO TYPE?! 17 | !! -------------^ 18 | !! compilation aborted for intel-20190909.f90 (code 1) 19 | !! 20 | 21 | subroutine external_sub 22 | implicit none 23 | real :: array1(5) 24 | do concurrent (integer :: j=1:5) 25 | array1(j) = 0 ! NO ERROR HERE -- J HAS A TYPE 26 | end do 27 | end subroutine 28 | 29 | module mod 30 | contains 31 | subroutine module_sub 32 | implicit none 33 | real :: array2(5) 34 | do concurrent (integer :: j=1:5) 35 | array2(j) = 0 ! ERROR HERE -- J HAS NO TYPE?! 36 | end do 37 | end subroutine 38 | end module 39 | -------------------------------------------------------------------------------- /intel-bugs/intel-20191228.f90: -------------------------------------------------------------------------------- 1 | !! Service Request Number: 04488016; fixed in 2021.10.0 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! Affects both 18.0.5 and 19.0.5. No error if string is not allocatable. 6 | !! 7 | !! $ ifort --version 8 | !! ifort (IFORT) 19.0.5.281 20190815 9 | !! 10 | !! $ ifort intel-20191228.f90 11 | !! intel-20191228.f90(4): catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error. 12 | !! compilation aborted for intel-20191228.f90 (code 1) 13 | 14 | character(:), allocatable :: string 15 | string = 'fubar' 16 | associate (substring => string(3:)) 17 | if (substring /= 'bar') stop 1 18 | end associate 19 | end 20 | -------------------------------------------------------------------------------- /intel-bugs/intel-20191229.f90: -------------------------------------------------------------------------------- 1 | !! Service Request Number: 04488021 2 | !! 3 | !! ALLOCATES LHS ARRAY WITH WRONG BOUNDS 4 | !! 5 | !! This is totally f*cked up. LHS allocatable array Z is not allocated 6 | !! with the bounds of Y, but with the bounds of the actual argument X. 7 | !! Affects 18.0.5 and 19.0.5 8 | !! 9 | !! $ ifort --version 10 | !! ifort (IFORT) 19.0.5.281 20190815 11 | !! $ ifort intel-20191229.f90 12 | !! $ ./a.out 13 | !! 2 14 | !! 15 | 16 | real, allocatable :: x(:) 17 | allocate(x(-2:0)) 18 | call foo(x) 19 | contains 20 | subroutine foo(y) 21 | real, intent(in) :: y(:) 22 | real, allocatable :: z(:) 23 | if (lbound(y,1) /= 1) stop 1 24 | z = y ! <== Z IS NOT ALLOCATED WITH THE CORRECT BOUNDS! 25 | if (lbound(z,1) /= lbound(y,1)) stop 2 ! <== EXITS HERE 26 | end subroutine 27 | end 28 | -------------------------------------------------------------------------------- /intel-bugs/intel-20200715.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nncarlson/fortran-compiler-tests/ce8fdcdf71d930629041fbaa3d144a8da961cdb2/intel-bugs/intel-20200715.tar.gz -------------------------------------------------------------------------------- /intel-bugs/intel-20200721.f90: -------------------------------------------------------------------------------- 1 | !! Support request 04744494 2 | !! 3 | !! VALID CODE REJECTED 4 | !! 5 | !! In the following example DUMMY%STATE is a valid argument to the 6 | !! STORAGE_SIZE intrinsic function. Neither the allocatable DUMMY 7 | !! variable nor its allocatable component STATE need to be allocated; 8 | !! the result depends only on the type of STATE which is known. 9 | !! 10 | !! $ ifort --version 11 | !! ifort (IFORT) 19.1.0.166 20191121 12 | !! 13 | !! $ ifort intel-20200721.f90 14 | !! intel-20200721.f90(16): error #8484: The argument to STORAGE_SIZE is invalid. [STATE] 15 | !! integer, parameter :: n = storage_size(dummy%state) 16 | !! -----------------------------------------------^ 17 | !! compilation aborted for intel-20200721.f90 (code 1) 18 | !! 19 | 20 | module mod 21 | type :: foo 22 | integer, allocatable :: state(:) 23 | end type 24 | type(foo), allocatable :: dummy 25 | integer, parameter :: n = storage_size(dummy%state) 26 | end module 27 | -------------------------------------------------------------------------------- /intel-bugs/intel-20210619.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 2021.11.0 2 | !! 3 | !! VALID CODE REJECTED 4 | !! 5 | !! In the following example DUMMY%STATE%X and BUFFER are both valid arguments 6 | !! to the STORAGE_SIZE intrinsic function. Neither the allocatable DUMMY 7 | !! variable nor its allocatable component STATE need to be allocated; 8 | !! the result depends only on the type of STATE%X which is known. 9 | !! This slight alteration of intel-20200721.f90 adds some similar instances 10 | !! of this usage. 11 | !! 12 | !! $ ifort --version 13 | !! ifort (IFORT) 2021.2.0 20210228 14 | !! 15 | !! $ ifort -c intel-20210619.f90 16 | !! intel-20210619.f90(30): error #8484: The argument to STORAGE_SIZE is invalid. [X] 17 | !! integer, parameter :: n = storage_size(dummy%state%x) 18 | !! -----------------------------------------------------^ 19 | !! intel-20210619.f90(34): error #8484: The argument to STORAGE_SIZE is invalid. [BUFFER] 20 | !! integer, parameter :: n = storage_size(buffer) 21 | !! -------------------------------------------^ 22 | !! compilation aborted for intel-20210619.f90 (code 1) 23 | !! 24 | 25 | module mod 26 | type :: bar 27 | integer :: x 28 | end type 29 | type :: foo 30 | type(bar), allocatable :: state(:) 31 | end type 32 | type(foo), allocatable :: dummy 33 | integer, parameter :: n = storage_size(dummy%state%x) ! VALID 34 | contains 35 | subroutine sub(buffer) 36 | integer :: buffer(:) 37 | integer, parameter :: n = storage_size(buffer) ! VALID 38 | end subroutine 39 | end module 40 | -------------------------------------------------------------------------------- /intel-bugs/intel-20220211.f90: -------------------------------------------------------------------------------- 1 | !! Bug report: CMPLRIL0-34602 2 | !! 3 | !! SPURIOUS BOUNDS ERROR FOR MISSING OPTIONAL ARGUMENT 4 | !! 5 | !! The bounds checking runtime should not be doing anything with a missing 6 | !! optional argument. Curiously there is no error if the array A is of integer type. 7 | !! 8 | !! $ ifort --version 9 | !! ifort (IFORT) 2021.5.0 20211109 10 | !! 11 | !! $ ifort -O0 -check shape -traceback intel-20220211.f90 12 | !! $ ./a.out 13 | !! forrtl: severe (408): fort: (33): Shape mismatch: The extent of dimension 1 of array X is 2 and the corresponding extent of array M is 0 14 | !! 15 | !! Image PC Routine Line Source 16 | !! a.out 00000000004065DF Unknown Unknown Unknown 17 | !! a.out 00000000004039F6 MAIN__ 29 intel-20220211.f90 18 | !! a.out 0000000000403862 Unknown Unknown Unknown 19 | !! libc-2.32.so 00007F1E9B4961E2 __libc_start_main Unknown Unknown 20 | !! a.out 000000000040376E Unknown Unknown Unknown 21 | 22 | program main 23 | 24 | real :: a(2) 25 | logical :: mask(2) 26 | 27 | a = [1,2] 28 | mask = [.true.,.false.] 29 | 30 | if (foo(a,mask) /= 1) stop 1 31 | if (foo(a) /= 2) stop 2 32 | 33 | contains 34 | 35 | real function foo(x, m) 36 | real, intent(in) :: x(:) 37 | logical, intent(in), optional :: m(:) 38 | foo = maxval(x, m) 39 | end function 40 | 41 | end program 42 | 43 | -------------------------------------------------------------------------------- /intel-bugs/intel-20230604.f90: -------------------------------------------------------------------------------- 1 | !! CMPLRLLVM-48376 2 | !! 3 | !! WRONG RESULT FROM COINDEXED ACTUAL ARGUMENT TO MATMUL 4 | !! 5 | !! This example exposes an error with the executable code for a MATMUL 6 | !! reference when one of its actual arguments is a multirank coindexed 7 | !! object. The example compares the result of that MATMUL with the 8 | !! value computed by first assigning the coindexed object to a local 9 | !! array and passing it instead. The error occurs for both ifort 2021.9 10 | !! and ifx 2023.1 11 | !! 12 | !! $ ifort -coarray -coarray-num-images=2 bug.f90 13 | !! $ ./a.out 14 | !! error on image 1 15 | !! c1= 2.000000 4.000000 6.000000 8.000000 16 | !! c2= 4.000000 2.000000 8.000000 6.000000 17 | !! 18 | 19 | program main 20 | real :: a(2,2), b(2,2)[*], c1(2,2), c2(2,2), tmp(2,2) 21 | a = reshape([0,1,1,0], shape=[2,2]) 22 | b = this_image()*reshape([1,2,3,4], shape=[2,2]) 23 | sync all 24 | if (this_image() < num_images()) then 25 | c1 = matmul(a, b(:,:)[this_image()+1]) ! EXCHANGES ROWS OF B 26 | tmp = b(:,:)[this_image()+1] 27 | c2 = matmul(a, tmp) 28 | if (any(c1 /= c2)) then 29 | print *, 'error on image', this_image() 30 | print *, 'c1=', c1 31 | print *, 'c2=', c2 32 | error stop 33 | end if 34 | end if 35 | end program 36 | -------------------------------------------------------------------------------- /intel-bugs/intel-20231122.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 2024.1 2 | !! Worked in ifort 2021.10, broken in 2024.11 (2024.0), fixed in 2024.12 (2024.1) 3 | !! 4 | !! INTERNAL COMPILER ERROR 5 | !! 6 | !! No ICE if fptr is declared in subroutine bar, or if fptr is default 7 | !! initialized to null(). This is with 2024.0 8 | !! 9 | !! $ ifx -c intel-20231122.f90 10 | !! #0 0x000000000232d5da 11 | !! #1 0x0000000002394df7 12 | !! [...] 13 | !! #28 0x00007fbe0056a609 __libc_start_main + 137 14 | !! #29 0x00000000020ab129 15 | !! 16 | !! intel-20231122.f90: error #5633: **Internal compiler error: segmentation violation signal raised** 17 | 18 | subroutine foo 19 | 20 | use,intrinsic :: iso_c_binding, only: c_funptr, c_f_procpointer 21 | 22 | abstract interface 23 | real function f(x) bind(c) 24 | real, value :: x 25 | end function 26 | end interface 27 | procedure(f), pointer :: fptr 28 | 29 | contains 30 | 31 | subroutine bar 32 | type(c_funptr) :: funptr 33 | ! code to initialize funptr 34 | call c_f_procpointer(funptr, fptr) 35 | end subroutine 36 | 37 | end subroutine 38 | -------------------------------------------------------------------------------- /intel-bugs/intel-20231123.f90: -------------------------------------------------------------------------------- 1 | !! CMPLRLLVM-53947 -- Fixed in 2024.2 (and ifort 21.13) 2 | !! 3 | !! REJECTS VALID CODE 4 | !! 5 | !! $ ifx intel-20231123.f90 6 | !! intel-20231123.f90: error #5286: Ambiguous generic interface NEW_SECURE_HASH: previously declared specific procedure SECURE_HASH_FACTORY::NEW_SECURE_HASH_ALLOC is not distinguishable from this declaration. [SECURE_HASH_FACTORY::NEW_SECURE_HASH_PTR] 7 | !! intel-20231123.f90(43): error #7496: A non-pointer actual argument shall have a TARGET attribute when associated with a pointer dummy argument. [H1] 8 | !! call new_secure_hash(h1) 9 | !! ---------------------^ 10 | !! compilation aborted for intel-20231123.f90 (code 1) 11 | 12 | module secure_hash_factory 13 | 14 | implicit none 15 | private 16 | 17 | public :: secure_hash, new_secure_hash 18 | 19 | type, abstract :: secure_hash 20 | end type 21 | 22 | interface new_secure_hash 23 | procedure new_secure_hash_alloc, new_secure_hash_ptr 24 | end interface 25 | 26 | contains 27 | 28 | subroutine new_secure_hash_alloc(hash) 29 | class(secure_hash), allocatable, intent(out) :: hash 30 | write(*,'(a)',advance='no') 'a' 31 | end subroutine 32 | 33 | subroutine new_secure_hash_ptr(hash) 34 | class(secure_hash), pointer, intent(out) :: hash 35 | write(*,'(a)',advance='no') 'p' 36 | end subroutine 37 | 38 | end module 39 | 40 | use secure_hash_factory 41 | class(secure_hash), allocatable :: h1 42 | class(secure_hash), pointer :: h2 43 | call new_secure_hash(h1) 44 | call new_secure_hash(h2) 45 | write(*,*) 46 | end 47 | -------------------------------------------------------------------------------- /intel-bugs/intel-20231210.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 2024.1 2 | !! 3 | !! REJECTS VALID CODE 4 | !! 5 | !! $ ifx --version 6 | !! ifx (IFX) 2024.0.0 20231017 7 | !! 8 | !! $ ifx intel-20231210.f90 9 | !! intel-20231210.f90(20): error #6512: A scalar-valued expression is required in this context. [X] 10 | !! if (x) print *, 'pass' ! X IS A SCALAR IN THIS RANK-CASE BLOCK 11 | !! ------------^ 12 | !! compilation aborted for intel-20231210.f90 (code 1) 13 | 14 | call foo(.true.) 15 | contains 16 | subroutine foo(x) 17 | class(*), intent(in) :: x(..) 18 | select rank (x) 19 | rank (0) 20 | select type (x) 21 | type is (logical) 22 | if (x) print *, 'pass' ! X IS A SCALAR IN THIS RANK-CASE BLOCK 23 | end select 24 | end select 25 | end subroutine 26 | end 27 | -------------------------------------------------------------------------------- /intel-bugs/intel-20231213.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 2025.1 2 | !! POOR OUTPUT WITH G0 REAL FORMATTING 3 | !! 4 | !! This may not be a bug at all, but rather merely what I consider to be a 5 | !! poor quality implementation choice permitted by the standard. 6 | !! 7 | !! With "-assume old_e0g0_format" ifx 2024.0 writes .5670000000000000E-13 8 | !! With "-assume noold_e0g0_format" (implied by -standard-semantics) it 9 | !! writes .6E-13 10 | !! 11 | 12 | use iso_fortran_env 13 | write(*,'(g0)') 5.67e-14_real64 14 | end 15 | -------------------------------------------------------------------------------- /intel-bugs/intel-20240327.f90: -------------------------------------------------------------------------------- 1 | !! CMPLRLLVM-57245. Fixed in 2025.0 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! Example involves F2018 assumed-type and assumed-rank character dummy argument. 6 | !! 7 | !! $ ifx --version 8 | !! ifx (IFX) 2024.0.2 20231213 9 | !! $ ifx -c intel-20240327.f90 10 | !! [...] 11 | !! intel-20240327.f90(31): error #5623: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error. 12 | !! call c_void_func([a]) 13 | !! ------------------------^ 14 | !! compilation aborted for intel-20240327.f90 (code 3) 15 | !! 16 | !! Also fails with ifort from 2024.0.2 with this error message which doesn't 17 | !! seem to be a normal error from invalid code: 18 | !! 19 | !! intel-20240327.f90(31): error #5529: CHARACTER variable 'A' has no length argument in routines with C or STDCALL attribute 20 | !! call c_void_func([a]) 21 | 22 | module foo 23 | interface 24 | subroutine c_void_func(b) bind(c) 25 | type(*), intent(in) :: b(*) 26 | end subroutine 27 | end interface 28 | contains 29 | subroutine bar(a) 30 | character(*), intent(in) :: a(..) 31 | select rank (a) 32 | rank (0) 33 | call c_void_func([a]) 34 | end select 35 | end subroutine 36 | end module 37 | -------------------------------------------------------------------------------- /intel-bugs/intel-20241010.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 2025.1 2 | !! INTERNAL COMPILER ERROR 3 | !! 4 | !! ifx intel-20241010.f90 5 | !! intel-20241010.f90(3): error #5623: **Internal compiler error: internal abort** 6 | !! 7 | 8 | complex :: x(5) 9 | x = 1.0 10 | x%im = -x%re 11 | end 12 | -------------------------------------------------------------------------------- /intel-bugs/intel-20241231.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! INCORRECT RESULT FROM MOVE_ALLOC 3 | !! 4 | !! $ ifx --version 5 | !! ifx (IFX) 2025.0.0 20241008 6 | !! 7 | !! $ ifx intel-20241231.f90 8 | !! $ ./a.out 9 | !! 1 (should produce no output -- return status 0) 10 | !! 11 | 12 | type,abstract :: foo 13 | end type 14 | type, extends(foo) :: bar 15 | end type 16 | type(bar), allocatable :: x 17 | class(foo), allocatable :: y 18 | call move_alloc(x, y) 19 | if (allocated(y)) stop 1 ! ERROR: Y SHOULD BE UNALLOCATED 20 | end 21 | -------------------------------------------------------------------------------- /intel-bugs/intel-20250428.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! VALID CODE REJECTED 3 | !! 4 | !! $ ifx --version 5 | !! ifx (IFX) 2025.1.0 20250317 6 | !! 7 | !! $ ifx -c intel-20250428.f90 8 | !! intel-20250428.f90(39): error #6582: A dummy argument which has the OPTIONAL or the INTENT(OUT) attribute is not allowed in this specification expression. [THIS] 9 | !! real :: array2(this%n) 10 | !! ---------------------^ 11 | !! intel-20250428.f90(34): error #6582: A dummy argument which has the OPTIONAL or the INTENT(OUT) attribute is not allowed in this specification expression. [THIS] 12 | !! real :: array1(this%n) 13 | !! ---------------------^ 14 | !! compilation aborted for intel-20250428.f90 (code 1) 15 | !! 16 | !! In both cases, THIS%N is an object designator with a base object (THIS) 17 | !! that is made accessible by host association (2018: 10.1.11 par 2, item 4) 18 | !! and is thus a restricted expression and a valid specification expression. 19 | !! 20 | 21 | module foo 22 | 23 | type :: bar 24 | integer :: n 25 | end type 26 | 27 | contains 28 | 29 | subroutine init(this, n) 30 | type(bar), intent(out) :: this 31 | integer, intent(in) :: n 32 | this%n = n 33 | block 34 | real :: array1(this%n) 35 | end block 36 | call sub 37 | contains 38 | subroutine sub 39 | real :: array2(this%n) 40 | end subroutine 41 | end subroutine 42 | 43 | end module 44 | -------------------------------------------------------------------------------- /intel-bugs/intel-20250605.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! REJECTS VALID /ICE / INCORRECT RESULTS 3 | !! 4 | !! The ifx 2025.1 compiler rejects the test1 code, segfaults on test2, 5 | !! and compiles test3 without error, but produces incorrect results. 6 | !! 7 | 8 | type :: foo 9 | complex :: z(3) 10 | end type 11 | 12 | call test1 13 | call test2 14 | call test3 15 | 16 | contains 17 | 18 | subroutine test1 19 | type(foo) :: a 20 | a%z%re = -1 21 | call bar(a%z%re) 22 | if (any(a%z%re /= [1,2,3])) stop 1 23 | a%z%im = -1 24 | call bar(a%z%im) 25 | if (any(a%z%im /= [1,2,3])) stop 2 26 | end subroutine 27 | 28 | subroutine test2 29 | type(foo) :: a 30 | a%z%re = -1 31 | associate (z => a%z) 32 | call bar(z%re) 33 | end associate 34 | if (any(a%z%re /= [1,2,3])) stop 3 35 | a%z%im = -1 36 | associate (z => a%z) 37 | call bar(z%im) 38 | end associate 39 | if (any(a%z%im /= [1,2,3])) stop 4 40 | end subroutine 41 | 42 | subroutine test3 43 | type(foo) :: a 44 | a%z%re = -1 45 | associate (z_re => a%z%re) 46 | call bar(z_re) 47 | end associate 48 | if (any(a%z%re /= [1,2,3])) stop 5 49 | a%z%im = -1 50 | associate (z_im => a%z%im) 51 | call bar(z_im) 52 | end associate 53 | if (any(a%z%im /= [1,2,3])) stop 6 54 | end subroutine 55 | 56 | subroutine bar(x) 57 | real, intent(inout) :: x(:) 58 | x = [1,2,3] 59 | end subroutine 60 | 61 | end 62 | -------------------------------------------------------------------------------- /nag-bugs/nag-20121007.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 5.3.1 (906) 2 | !! 3 | !! In the example below, the specific binding for the type-bound assignment 4 | !! does not have the object passed as one of the arguments (NOPASS). This 5 | !! violates C468 (R450): "If generic-spec is not generic-name, each of its 6 | !! specific bindings shall have a passed-object dummy argument (4.5.4.5)." 7 | !! The NAG compiler lets this slip past without error. (The defined 8 | !! assignment does work as expected, however.) 9 | !! 10 | !! % nagfor -version 11 | !! NAG Fortran Compiler Release 5.3.1 pre-release(904) 12 | !! 13 | !! % nagfor -c nag-bug-20121007.f90 14 | !! NAG Fortran Compiler Release 5.3.1 pre-release(904) 15 | !! [NAG Fortran Compiler normal termination] 16 | !! 17 | 18 | module example 19 | 20 | type :: some_type 21 | integer :: n 22 | contains 23 | procedure, nopass, private :: copy 24 | generic :: assignment(=) => copy 25 | end type 26 | 27 | contains 28 | 29 | subroutine copy (a, b) 30 | class(some_type), intent(inout) :: a 31 | class(some_type), intent(in) :: b 32 | a%n = b%n 33 | end subroutine 34 | 35 | end module 36 | -------------------------------------------------------------------------------- /nag-bugs/nag-20121111.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 5.3.1 (917) 2 | !! 3 | !! BAD INTERMEDIATE C CODE WITH -C=ALL OPTION 4 | !! 5 | !! The 5.3.1 edit 913 compiler generates bad intermediate C code 6 | !! for the following example when compiled with -C=all. 7 | !! 8 | !! % nagfor -C=all -c nag-bug-20121111.f90 9 | !! NAG Fortran Compiler Release 5.3.1(913) 10 | !! [NAG Fortran Compiler normal termination] 11 | !! nag-bug-20121111.f90: In function 'sub_': 12 | !! nag-bug-20121111.f90:32:10: error: request for member 'compa_' in something not a structure or union 13 | !! nag-bug-20121111.f90:32:194: error: request for member 'compa_' in something not a structure or union 14 | !! 15 | 16 | module mod 17 | type :: typeA 18 | integer, pointer :: array(:) 19 | end type 20 | type :: typeB 21 | type(typeA) :: compA 22 | end type 23 | end module 24 | 25 | subroutine sub (varB, vector) 26 | use mod 27 | type(typeB) :: varB 28 | integer :: vector(:) 29 | print *, count(vector(varB%compA%array) /= varB%compA%array) 30 | end subroutine 31 | -------------------------------------------------------------------------------- /nag-bugs/nag-20131204.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 5.3.2 (975) 2 | !! 3 | !! The NAG 5.3 compiler (edit 973) is generating invalid intermediate C 4 | !! code for the following example when compiled with the -C=all option. 5 | !! It compiles without error without that option. It appears that the 6 | !! abstract interface is improperly leaking outside of the module. 7 | !! 8 | !! $ nagfor -c -C=all nag-bug-20131204.f90 9 | !! NAG Fortran Compiler Release 5.3.2(973) 10 | !! [NAG Fortran Compiler normal termination] 11 | !! nag-bug-20131204.f90: In function 'example_': 12 | !! nag-bug-20131204.f90:2:13: error: 'strain_rate_' redeclared as different kind of symbol 13 | !! nag-bug-20131204.f90:31:28: note: previous definition of 'strain_rate_' was here 14 | !! nag-bug-20131204.f90:35:33: error: invalid operands to binary + (have 'Real (*)()' and 'Real') 15 | !! 16 | 17 | module vp_model_class 18 | private 19 | type, abstract, public :: vp_model 20 | contains 21 | procedure(strain_rate), deferred :: strain_rate 22 | end type 23 | abstract interface 24 | function strain_rate (this) 25 | import :: vp_model 26 | class(vp_model), intent(in) :: this 27 | end function 28 | end interface 29 | end module VP_model_class 30 | 31 | 32 | subroutine example (model, strain_rate) 33 | use vp_model_class 34 | class(vp_model) :: model 35 | real :: strain_rate 36 | strain_rate = strain_rate + model%strain_rate() 37 | end subroutine 38 | -------------------------------------------------------------------------------- /nag-bugs/nag-20140108.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 5.3.2 (978) 2 | !! 3 | !! INVALID INTERMEDIATE C CODE 4 | !! 5 | !! The NAG 5.3 compiler (edit 975) is generating invalid intermediate C 6 | !! code for the following example when compiled with the -nan option. 7 | !! It compiles without error without that option. 8 | !! 9 | !! $ nagfor -nan -c nag-bug-20140108.f90 10 | !! NAG Fortran Compiler Release 5.3.2(975) 11 | !! [NAG Fortran Compiler normal termination] 12 | !! nag-bug-20140108.f90:18:45: error: "mod_EQ" undeclared here (not in a function) 13 | !! module mod 14 | !! ^ 15 | !! nag-bug-20140108.f90:18:52: error: invalid suffix "mod_MP_x" on floating constant 16 | !! module mod 17 | !! 18 | 19 | module mod 20 | real :: x 21 | contains 22 | subroutine sub 23 | namelist /nml/ x 24 | end subroutine 25 | end module 26 | -------------------------------------------------------------------------------- /nag-bugs/nag-20140417.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 5.3.2 (983) 2 | !! 3 | !! COMPILER PANIC 4 | !! 5 | !! The NAG compiler version 5.3.2(981) panics on the following code. 6 | !! 7 | !! % nagfor -c HTSD_model_type.f90 8 | !! NAG Fortran Compiler Release 5.3.2(981) 9 | !! Panic: HTSD_model_type.f90: mkarraydesc unexpected node type 467 10 | !! Internal Error -- please report this bug 11 | !! 12 | 13 | module T1_mod 14 | type :: T1 15 | integer, pointer :: foo => null() 16 | contains 17 | final :: T1_delete 18 | end type 19 | contains 20 | subroutine T1_delete (this) 21 | type(T1) :: this 22 | print *, 'T1_delete' 23 | end subroutine 24 | end module 25 | 26 | module T2_mod 27 | use T1_mod 28 | type :: T2 29 | type(T1) :: x 30 | end type 31 | end module 32 | 33 | module T3_mod 34 | use T2_mod 35 | type :: T3 36 | type(T2), pointer :: array(:) => null() 37 | end type 38 | contains 39 | subroutine delete (this) 40 | type(T3) :: this 41 | deallocate(this%array) 42 | end subroutine 43 | end module 44 | 45 | program main 46 | use T3_mod 47 | use T2_mod 48 | type(T3) :: x 49 | type(T3), allocatable :: y 50 | type(T2), pointer :: a(:) 51 | ! Try 1 52 | allocate(x%array(5)) 53 | call delete (x) 54 | ! Try 2 55 | allocate(y) 56 | allocate(y%array(5)) 57 | call delete (y) 58 | ! Try 3 59 | allocate(a(5)) 60 | x%array => a 61 | call delete (x) 62 | end program 63 | -------------------------------------------------------------------------------- /nag-bugs/nag-20140616.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 5.3.2 (989) -- Issue number 88538 2 | !! 3 | !! Internal Compiler Error 4 | !! 5 | !! The following example triggers an internal compiler error with 6 | !! the NAG 5.3.2 (983) compiler. I believe it is standard conforming. 7 | !! 8 | !! % nagfor nag-bug-20140616.f90 9 | !! NAG Fortran Compiler Release 5.3.2(983) 10 | !! Panic: nag-bug-20140616.f90: Unknown data type (0,0) in cdtype_size 11 | !! Internal Error -- please report this bug 12 | !! Abort 13 | !! 14 | 15 | program main 16 | class(*), allocatable, target :: array(:) 17 | class(*), pointer :: ptr(:,:) 18 | allocate(array(4), source=[1,2,3,4]) 19 | ptr(1:2,1:2) => array ! <=== STATEMENT THAT CAUSES THE ICE 20 | select type (ptr) 21 | type is (integer) 22 | print *, ptr 23 | end select 24 | end program 25 | -------------------------------------------------------------------------------- /nag-bugs/nag-20140617.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 5.3.2 (989) -- Issue number 88549 2 | !! 3 | !! POINTER ASSIGNMENT NOT DEFINING DEFERRED LENGTH PARAMETER 4 | !! 5 | !! In the following example, the second pointer assignment involving 6 | !! rank remapping is not properly defining the deferred length parameter 7 | !! of the pointer object (see F2008 5.3.14 #3). 8 | !! 9 | !! The code works correctly if ARRAY is declared as CHARACTER(:) and the 10 | !! SELECT-TYPE construct eliminated. 11 | !! 12 | !! % nagfor nag-bug-20140617.f90 13 | !! NAG Fortran Compiler Release 5.3.2(983) 14 | !! [NAG Fortran Compiler normal termination] 15 | !! % ./a.out 16 | !! len= 3 (expect 3 ) 17 | !! len= 0 (expect 3 ) <=== THIS IS WRONG 18 | !! 19 | 20 | program main 21 | class(*), allocatable, target :: array(:) 22 | character(:), pointer :: ptr1(:), ptr2(:,:) 23 | allocate(array(1), source=['foo']) 24 | select type (array) 25 | type is (character(*)) 26 | !ptr1 => array ! THIS WORKS 27 | !print *, 'len=', len(ptr1), ' (expect', len(array), ')' 28 | ptr2(1:1,1:1) => array ! THIS DOES NOT WORK 29 | print '(a,2(i0,a))', 'len=', len(ptr2), ' (expect ', len(array), ')' 30 | end select 31 | end program 32 | -------------------------------------------------------------------------------- /nag-bugs/nag-20150520.f90: -------------------------------------------------------------------------------- 1 | !! fixed in 6.0 (1052) 2 | !! 3 | !! ERROR PARSING KEYWORD ARGUMENT 4 | !! 5 | !! In the example below, the compiler takes spurious issue 6 | !! with the assignment statement involving the intrinsic 7 | !! elemental function IBSET. It reports no error when 8 | !! compiled with -O0, but an error with -O1 or -O2. The 9 | !! error appears to be coming from the backend C compiler. 10 | !! 11 | !! % nagfor -O2 -c nag-bug-20150520.f90 12 | !! NAG Fortran Compiler Release 6.0(Hibiya) Build 1049 13 | !! [NAG Fortran Compiler normal termination] 14 | !! nag-bug-20150520.f90: In function 'fubar_MP_foo': 15 | !! nag-bug-20150520.f90:30:34: error: invalid operands to binary << (have 'int' and 'AAType1') 16 | !! arg%mask = ibset(arg%mask, pos=arg%pos) 17 | !! ^ 18 | !! Note that the error goes away if (unnnecessary) "pos=" keyword 19 | !! specification is omitted. 20 | !! 21 | 22 | module fubar 23 | type :: mytype 24 | integer, allocatable :: mask(:) 25 | integer, allocatable :: pos(:) 26 | end type 27 | contains 28 | subroutine foo (arg) 29 | type(mytype) :: arg 30 | arg%mask = 0 31 | arg%mask = ibset(arg%mask, pos=arg%pos) 32 | end subroutine 33 | end module 34 | 35 | -------------------------------------------------------------------------------- /nag-bugs/nag-20150528-main.f90: -------------------------------------------------------------------------------- 1 | 2 | module sm_module 3 | 4 | use module_with_ptr_object 5 | use const_scalar_func_type 6 | use scalar_func_factories_EXPORTS_NOTHING 7 | use my_func_type 8 | 9 | contains 10 | 11 | subroutine solid_mech_init 12 | call define_ptr_object_and_contents 13 | call get_ptr_object_func 14 | end subroutine 15 | 16 | subroutine define_ptr_object_and_contents 17 | 18 | integer :: stat 19 | class(scalar_func), allocatable :: unused1, unused2, dummy, rho 20 | character(80) :: errmsg 21 | character(:), allocatable :: unused3 22 | 23 | allocate(const_scalar_func :: dummy) 24 | 25 | call alloc_my_func (rho, stat, errmsg) 26 | if (stat /= 0) errmsg = 'x' // trim(errmsg) ! NOT EXECUTED 27 | call move_func_to_ptr_component (rho) 28 | 29 | end subroutine 30 | 31 | subroutine get_ptr_object_func 32 | class(scalar_func), allocatable :: f 33 | call get_copy_of_ptr_func_component (f) 34 | end subroutine 35 | 36 | end module sm_module 37 | 38 | program main 39 | use sm_module 40 | call solid_mech_init 41 | end program 42 | -------------------------------------------------------------------------------- /nag-bugs/nag-20160129-main.f90: -------------------------------------------------------------------------------- 1 | program main 2 | 3 | use a_type 4 | type(a) :: x, y(2) 5 | 6 | call x%sub ([1,2]) 7 | call y%sub ([1,2]) 8 | 9 | print *, x%n, '(expect 3)' 10 | print *, y%n, '(expect 1 2)' 11 | 12 | end program 13 | 14 | -------------------------------------------------------------------------------- /nag-bugs/nag-20160129.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! The following program, as a single file, compiles without error and 3 | !! prints the expected result. But when the main program is moved to a 4 | !! separate file (main.f90) the compiler reports an error: 5 | !! 6 | !! % nagfor nag-bug-20160129.f90 main.f90 7 | !! NAG Fortran Compiler Release 6.0(Hibiya) Build 1067 8 | !! nag-bug-20160129.f90: 9 | !! [NAG Fortran Compiler normal termination] 10 | !! main.f90: 11 | !! Error: main.f90, line 6: Scalar actual for INTENT(INOUT) dummy THIS of elemental SUB_ELEM, but another argument is an array 12 | !! [NAG Fortran Compiler error termination, 1 error] 13 | !! 14 | 15 | module a_type 16 | 17 | type :: a 18 | integer :: n 19 | contains 20 | procedure :: sub_elem 21 | procedure :: sub_array 22 | generic :: sub => sub_elem, sub_array 23 | end type 24 | 25 | contains 26 | 27 | elemental subroutine sub_elem (this, arg) 28 | class(a), intent(inout) :: this 29 | integer, intent(in) :: arg 30 | this%n = arg 31 | end subroutine 32 | 33 | subroutine sub_array (this, arg) 34 | class(a), intent(inout) :: this 35 | integer, intent(in) :: arg(:) 36 | this%n = sum(arg) 37 | end subroutine 38 | 39 | end module 40 | 41 | !program main 42 | ! 43 | ! use a_type 44 | ! type(a) :: x, y(2) 45 | ! 46 | ! call x%sub ([1,2]) 47 | ! call y%sub ([1,2]) 48 | ! 49 | ! print *, x%n, '(expect 3)' 50 | ! print *, y%n, '(expect 1 2)' 51 | ! 52 | !end program 53 | 54 | -------------------------------------------------------------------------------- /nag-bugs/nag-20160321.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! In the following example SUB3 has an explicit interface but the 1070 edit 3 | !! of the 6.0 compiler incorrectly reports an error, claiming it has been 4 | !! implicitly typed in the call to SUB1 where it is passed as a procedure 5 | !! argument. The error goes away if SUB3 is moved before SUB2, or if the 6 | !! call to SUB3 is moved before the call to SUB1. This is a regresson from 7 | !! the 1067 edit and earlier compiler versions (e.g. 5.3.2). 8 | !! 9 | !! % nagfor -c nag-bug-20160321.f90 10 | !! NAG Fortran Compiler Release 6.0(Hibiya) Build 1070 11 | !! Warning: nag-bug-20160321.f90, line 8: Unused dummy procedure FOO 12 | !! Error: nag-bug-20160321.f90, line 11: Symbol SUB3 has already been implicitly typed 13 | !! detected at SUB3@ 14 | !! 15 | 16 | module mod 17 | contains 18 | subroutine sub1 (foo) 19 | interface 20 | subroutine foo 21 | end 22 | end interface 23 | end 24 | subroutine sub2 25 | call sub1 (sub3) 26 | call sub3 27 | end 28 | subroutine sub3 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /nag-bugs/nag-20170805a.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! The IMPLICIT NONE statement causes the compiler to regard C_INT in the 3 | !! function declaration as undeclared even though its definition is imported 4 | !! into the function scope by the IMPORT statement. 5 | !! 6 | !! Same erroneous behavior if the IMPLICIT NONE is removed and the "-u" 7 | !! compile option used. 8 | !! 9 | !! $ nagfor -c nag-bug-20170805.f90 10 | !! NAG Fortran Compiler Release 6.1(Tozai) Build 6136 11 | !! Error: nag-bug-20170805.f90, line 21: Implicit type for C_INT in FOO 12 | !! detected at IMPLICIT@NONE 13 | !! [NAG Fortran Compiler pass 1 error termination, 1 error] 14 | !! 15 | 16 | program main 17 | use iso_c_binding 18 | interface 19 | integer(c_int) function foo() bind(c) 20 | import 21 | implicit none 22 | end function 23 | end interface 24 | print *, foo() 25 | end program 26 | -------------------------------------------------------------------------------- /nag-bugs/nag-20171027.f90: -------------------------------------------------------------------------------- 1 | !! $ nagfor -c nag-bug-20171027.f90 2 | !! NAG Fortran Compiler Release 6.1(Tozai) Build 6140 3 | !! Panic: nag-bug-20171027.f90: isobject called with the wrong subtree 4 | !! Internal Error -- please report this bug 5 | !! Abort 6 | 7 | module example 8 | 9 | type, abstract :: foo 10 | integer, allocatable :: array(:) 11 | end type 12 | 13 | type :: bar 14 | class(foo), allocatable :: x 15 | end type 16 | 17 | contains 18 | 19 | subroutine sub (mask, a) 20 | type(bar), intent(inout) :: a 21 | logical :: mask(:) 22 | print *, any(mask(a%x%array)) 23 | ! workaround that avoids the ICE 24 | !associate (array => a%x%array) 25 | ! print *, any(mask(array)) 26 | !end associate 27 | end subroutine 28 | 29 | end module 30 | -------------------------------------------------------------------------------- /nag-bugs/nag-20171110.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 6.1 build 6144 (report 99312) 2 | !! 3 | !! Bad intermediate C code is being generated for this example 4 | !! resulting in errors from the C compiler. 5 | !! 6 | !! $ nagfor -c nag-bug-20171110.f90 7 | !! NAG Fortran Compiler Release 6.1(Tozai) Build 6143 8 | !! Warning: nag-bug-20171110.f90, line 42: Unused dummy variable THIS 9 | !! Warning: nag-bug-20171110.f90, line 46: Unused dummy variable THIS 10 | !! Warning: nag-bug-20171110.f90, line 46: INTENT(OUT) dummy argument THIS never set 11 | !! [NAG Fortran Compiler normal termination, 3 warnings] 12 | !! nag-bug-20171110.f90: In function 'fubar_MP_init': 13 | !! nag-bug-20171110.f90:44:14: error: 'this_' is a pointer; did you mean to use '->'? 14 | !! subroutine init(this) 15 | !! ^ 16 | !! -> 17 | !! nag-bug-20171110.f90: In function 'fubar_MP__zfinal0': 18 | !! nag-bug-20171110.f90:21:11: error: 'v_' is a pointer; did you mean to use '->'? 19 | !! module fubar 20 | !! ^ 21 | !! -> 22 | 23 | module fubar 24 | 25 | type x 26 | contains 27 | final :: x_final 28 | end type 29 | 30 | type y 31 | type(x) :: xval 32 | end type 33 | 34 | type z 35 | type(y) :: yval(2) 36 | contains 37 | procedure :: init 38 | end type 39 | 40 | contains 41 | 42 | elemental subroutine x_final(this) 43 | type(x), intent(inout) :: this 44 | end subroutine 45 | 46 | subroutine init(this) 47 | class(z), intent(out) :: this 48 | end subroutine 49 | 50 | end module 51 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180201.f90: -------------------------------------------------------------------------------- 1 | !! SR99906. Fixed in 6.2 build 6207, 6.1 build 6148 2 | !! 3 | !! INVALID INTERMEDIATE C CODE (FINALIZATION) 4 | !! 5 | !! The NAG 6.1 compiler generates invalid intermediate C code for the 6 | !! following example. 7 | !! 8 | !! Same for the 6.2 (6105) compiler. 9 | !! 10 | !! $ nagfor nag-20180201.f90 11 | !! NAG Fortran Compiler Release 6.1(Tozai) Build 6144 12 | !! Warning: nag-20180201.f90, line 24: Unused dummy variable THIS 13 | !! [NAG Fortran Compiler normal termination, 1 warning] 14 | !! nag-20180201.f90: In function 'main': 15 | !! nag-20180201.f90:30:11: error: 'x_' is a pointer; did you mean to use '->'? 16 | !! deallocate(x) 17 | !! ^ 18 | !! -> 19 | 20 | module outer_type 21 | type :: inner 22 | !integer, pointer :: foo => null() 23 | contains 24 | final :: delete 25 | end type 26 | type :: middle 27 | type(inner) :: scalar 28 | end type 29 | type :: outer 30 | type(middle) :: array(3) 31 | end type 32 | contains 33 | subroutine delete(this) 34 | type(inner), intent(inout) :: this 35 | !if (associated(this%foo)) deallocate(this%foo) 36 | end subroutine 37 | end module 38 | 39 | use outer_type 40 | type(outer), allocatable :: x 41 | allocate(x) 42 | deallocate(x) 43 | end 44 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180202a.f90: -------------------------------------------------------------------------------- 1 | !! SR99908. Fixed in 6.2 build 6207 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! The NAG 6.2 compiler, but not 6.1, gives an internal error 6 | !! for the following example. 7 | !! 8 | !! The ICE goes away if CLASS is replaced by TYPE. 9 | !! 10 | !! $ nagfor nag-20180202a.f90 11 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 12 | !! Panic: nag-20180202a.f90: Unexpected DEREF in expr 13 | !! Internal Error -- please report this bug 14 | !! Abort 15 | 16 | program main 17 | type foo 18 | integer :: n = 1 19 | end type 20 | type(foo), allocatable :: array(:) 21 | allocate(array, source=foo_array()) 22 | if (size(array) /= 2) stop 1 23 | if (any(array%n /= [1,1])) stop 2 24 | contains 25 | function foo_array() 26 | class(foo), allocatable :: foo_array(:) 27 | allocate(foo_array(2)) 28 | end function 29 | end 30 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180202b.f90: -------------------------------------------------------------------------------- 1 | !! SR99909. Fixed in 6.2 build 6207 2 | !! 3 | !! NAG: Not valid F2003, but valid F2008. Listed as an unsupported 4 | !! F2008 feature of NAG 6.1 5 | !! 6 | !! The presence of the external function FOO seems to be confusing 7 | !! the NAG compiler when it gets to the interface block within the 8 | !! main program. That should define a local FOO procedure, having 9 | !! nothing to do with the external FOO, which binds to the external 10 | !! BAR procedure. The error goes away if the external FOO procedure 11 | !! is commented out 12 | !! 13 | !! $ nagfor nag-20180202b.f90 14 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 15 | !! Error: nag-20180202b.f90: INTERFACE block for FOO from MAIN should not have the BIND(C) attribute 16 | !! Error: nag-20180202b.f90: Wrong number of arguments to FOO from MAIN: 1 found, 0 expected 17 | !! [NAG Fortran Compiler error termination, 2 errors] 18 | !! 19 | !! I see no constrain in the F08 standard that prohibits a BIND 20 | !! attribute on an interface block procedure. 21 | !! 22 | 23 | integer function foo(x) 24 | integer :: x 25 | foo = 2+0*x 26 | end function 27 | 28 | integer function bar() bind(c) 29 | bar = 1 30 | end function 31 | 32 | program main 33 | interface 34 | integer function foo() bind(c,name='bar') 35 | end function 36 | end interface 37 | if (foo() /= 1) stop 1 38 | end program 39 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180203a.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 6.2 build 6207. 6.1 status? 2 | !! 3 | !! INVALID INTERMEDIATE C CODE -- 3-ARG BESSEL_JN VERSION 4 | !! 5 | !! NAG Fortran 6.1 and 6.2 generates invalid C code for the following example. 6 | !! 7 | !! $ nagfor nag-20180203a.f90 -c 8 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 9 | !! [NAG Fortran Compiler normal termination] 10 | !! nag-20180203a.f90: In function 'bar_': 11 | !! nag-20180203a.f90:4:18: error: too many arguments to function '__NAGf90_jn_f' 12 | !! array = bessel_jn(1,n,x) 13 | !! ^~~~~~~~~ 14 | !! In file included from /opt/nag/nagfor-6.2/lib/nagfortran.h:133:0, 15 | !! from nag-20180203a.f90:1: 16 | !! /opt/nag/nagfor-6.2/lib/libfm.h:119:19: note: declared here 17 | !! VPure float CDECL __NAGf90_jn_f(INT64 n,float x); 18 | 19 | subroutine bar(n,x,array) 20 | integer n 21 | real x, array(n) 22 | array = bessel_jn(1,n,x) 23 | end subroutine 24 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180203c.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! PARENT COMPONENT NAME NOT THE RENAMED PARENT TYPE 3 | !! 4 | !! The NAG compiler gives this error for the following example: 5 | !! 6 | !! $ nagfor nag-20180203c.f90 7 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 8 | !! Error: nag-bug-20180203c.f90, line 12: POINT is not a component of P 9 | !! detected at %@POINT 10 | !! 11 | !! I don't think this is correct. The name of the parent component is POINT 12 | !! and not PUNKT. From the F08 standard: 13 | !! 14 | !! Note 4.51: "The name of the parent type might be a local name introduced 15 | !! via renaming in a USE statement." Here that is POINT. 16 | !! 17 | !! 4.5.7.2: "An extended type has a scalar, nonpointer, nonallocatable, parent 18 | !! component with [...] The name of this component is the parent type name. 19 | !! 20 | 21 | module punkt_type 22 | type punkt 23 | real x, y 24 | end type 25 | end module 26 | 27 | use punkt_type, only: point => punkt 28 | type, extends(point) :: color_point ! Note 4.51 (F08) POINT is the name of the parent type 29 | integer color 30 | end type 31 | type(color_point) :: p 32 | p%point%x = 1.0 ! THE PARENT COMPONENT SHOULD BE P%POINT, NOT P%PUNKT 33 | end 34 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180203e.f90: -------------------------------------------------------------------------------- 1 | !! The IMPLICIT NONE statement causes the compiler to regard S in the function 2 | !! declaration as undeclared even though its type is declared in the body of 3 | !! the function. This is eerily similar to SR98771 which I reported (and NAG 4 | !! fixed for 6.1) back in Aug '17. 5 | !! 6 | !! $ nagfor -c nag-20180203e.f90 7 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 8 | !! Error: nag-20180203e.f90, line 16: Implicit type for S 9 | !! detected at (@S 10 | !! Error: nag-20180203e.f90, line 17: Symbol S has already been implicitly typed 11 | !! detected at S@ 12 | 13 | module mod 14 | implicit none 15 | contains 16 | character(len(s)) function foo(s) 17 | character(*), intent(in) :: s 18 | foo = s 19 | end function 20 | end module 21 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180203f.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 6.2 build 6207 2 | !! 3 | !! INVALID INTERMEDIATE C CODE 4 | !! 5 | !! The NAG 6.2 compiler generates invalid intermediate C code 6 | !! for the following example. 7 | !! 8 | !! $ nagfor nag-20180203f.f90 9 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 10 | !! [NAG Fortran Compiler normal termination] 11 | !! nag-20180203f.f90: In function 'MAINIP_foo': 12 | !! nag-20180203f.f90:20:1: error: 'locals' undeclared (first use in this function) 13 | !! foo = 42 14 | !! ^ ~~ 15 | !! nag-20180203f.f90:20:1: note: each undeclared identifier is reported only once for each function it appears in 16 | 17 | 18 | call test 19 | contains 20 | integer function foo() 21 | foo = 42 22 | end function 23 | subroutine test 24 | procedure(integer), pointer :: x => null() 25 | x => foo 26 | print *, x() 27 | end subroutine 28 | end 29 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180204a.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! PASS NOT WORKING FOR PROCEDURE POINTER COMPONENTS 3 | !! 4 | !! The matching of actual arguments to dummy arguments is not working 5 | !! correctly when the passed-object is preceded by optional arguments 6 | !! that are omitted. 12.5.2.1 says that the actual arguments should 7 | !! be matched to the reduced dummy argument list, and "The reduced dummy 8 | !! argument list is either the full dummy argument list or, if there is 9 | !! a passed-object dummy argument, the dummy argument list with the 10 | !! passed-object dummy argument omitted. 11 | !! 12 | !! $ nagfor nag-20180204a.f90 13 | !! NAG Fortran Compiler Release 6.1(Tozai) Build 6144 14 | !! Warning: nag-20180204a.f90, line 26: Unused dummy variable B 15 | !! Error: nag-20180204a.f90, line 32: Incorrect data type FOO (expected 16 | !! INTEGER) for argument A (no. 1) of X%BAR 17 | 18 | module mod 19 | type foo 20 | procedure(bar), pointer, pass(b) :: bar 21 | end type 22 | contains 23 | subroutine bar(a, b) 24 | integer, intent(in), optional :: a 25 | class(foo), intent(in) :: b 26 | print *, present(a) 27 | end subroutine 28 | end module 29 | 30 | use mod 31 | type(foo) :: x 32 | x%bar => bar 33 | call x%bar() 34 | end 35 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180204b.f90: -------------------------------------------------------------------------------- 1 | !! SR99921. Fixed in 6.2 build 6207 2 | !! 3 | !! BAD INTERMEDIATE C CODE -- LIST-DIRECTED I/O OF PDT 4 | !! 5 | !! The NAG 6.2 compiler generates invalid C code for this example. It seems 6 | !! to be specific to the character type component; there are no errors if it 7 | !! is replaced by a real array, for example 8 | !! $ nagfor nag-20180204b.f90 9 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 10 | !! [NAG Fortran Compiler normal termination] 11 | !! nag-20180204b.f90: In function 'main': 12 | !! nag-20180204b.f90:25:122: error: 'struct _PDT_UNKNOWNLEN_MAINDT_foo' has no member named 'addr' 13 | !! write(buffer,*) var 14 | !! ^ 15 | !! nag-20180204b.f90:26:7: error: incompatible types when assigning to type 'struct _PDT_UNKNOWNLEN_MAINDT_foo *' from type '__NAGf90_LPDT_Pointer {aka struct }' 16 | !! read(buffer,*) var 17 | 18 | type foo(nlen) 19 | integer,len :: nlen 20 | character(nlen) :: name 21 | end type 22 | 23 | character(80) :: buffer 24 | type(foo(:)), allocatable :: var 25 | 26 | var = foo(3)('abc') 27 | write(buffer,*) var 28 | read(buffer,*) var 29 | 30 | end 31 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180204c.f90: -------------------------------------------------------------------------------- 1 | !! SR99921. Fixed in 6.2 build 6212 2 | !! 3 | !! SPURIOUS COMPILE ERROR WITH PDT AND EXTENSION 4 | !! 5 | !! The NAG 6.2 compiler gives this compile error for the following example 6 | !! 7 | !! $ nagfor nag-20180204c.f90 8 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 9 | !! Fatal Error: nag-20180204c.f90: Extension FOO of length type parameter dependent type BAR adds component N 10 | !! 11 | !! I believe this is spurious error. The Intel and gfortran compilers 12 | !! accept the code. In addition, if the declaration of the DIM variable 13 | !! used in the ALLOCATE statement is moved as indicated below (a completely 14 | !! innocuous change) the error goes away. I also don't understand the 15 | !! error message; "extension BAR of [...] type FOO" would make more sense. 16 | 17 | module vars 18 | integer :: dim = 4 19 | end module 20 | 21 | use vars ! ERROR IF DIM GOTTEN THROUGH USE 22 | !integer :: dim=4 ! NO ERROR IF DIM IS A LOCAL VARIABLE 23 | 24 | type :: foo(dim) 25 | integer,len :: dim 26 | real :: array(dim) 27 | end type 28 | 29 | type, extends(foo) :: bar 30 | integer :: n 31 | end type 32 | 33 | class(foo(:)), allocatable :: var 34 | allocate(bar(dim) :: var) 35 | 36 | end 37 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180204d.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 6.2 build 6216. 2 | !! 3 | !! INTERNAL COMPILER ERROR -- UNFORMATTED SEQUENCE DT INPUT 4 | !! 5 | !! This example triggers an internal compiler error with the NAG 6.2 compiler. 6 | !! 7 | !! $ nagfor -w=uda nag-20180204d.f90 8 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 9 | !! Panic: nag-20180204d.f90: Unexpected expr node type 290 10 | !! Internal Error -- please report this bug 11 | 12 | module foo_type 13 | 14 | type :: foo 15 | sequence 16 | integer :: a, b 17 | end type 18 | 19 | interface read(unformatted) 20 | module procedure foo_ufr 21 | end interface 22 | 23 | interface write(unformatted) 24 | module procedure foo_ufw 25 | end interface 26 | 27 | contains 28 | 29 | subroutine foo_ufr(dtv, unit, iostat, iomsg) 30 | type(foo), intent(inout) :: dtv 31 | integer, intent(in) :: unit 32 | integer, intent(out) :: iostat 33 | character(*), intent(inout) :: iomsg 34 | read(unit) dtv%a, dtv%b 35 | end subroutine 36 | 37 | subroutine foo_ufw(dtv, unit, iostat, iomsg) 38 | type(foo), intent(in) :: dtv 39 | integer, intent(in) :: unit 40 | integer, intent(out) :: iostat 41 | character(*), intent(inout) :: iomsg 42 | write(unit) dtv%a, dtv%b 43 | end subroutine 44 | 45 | end module 46 | 47 | use foo_type 48 | integer :: lun 49 | type(foo) :: var = foo(1,2) 50 | open(newunit=lun,status='scratch',form='unformatted') 51 | write(lun) var 52 | rewind(lun) 53 | read(lun) var ! THIS LINE TRIGGERS THE ICE 54 | end 55 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180204e.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 6.2 build 6216. 2 | !! 3 | !! INTERNAL COMPILER ERROR -- UNFORMATTED BIND DT INPUT 4 | !! 5 | !! This example triggers an internal compiler error with the NAG 6.2 compiler. 6 | !! 7 | !! $ nagfor -w=uda nag-20180204e.f90 8 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 9 | !! Panic: nag-20180204e.f90: Unexpected expr node type 290 10 | !! Internal Error -- please report this bug 11 | 12 | module foo_type 13 | 14 | type, bind(c) :: foo 15 | integer :: a, b 16 | end type 17 | 18 | interface read(unformatted) 19 | module procedure foo_ufr 20 | end interface 21 | 22 | interface write(unformatted) 23 | module procedure foo_ufw 24 | end interface 25 | 26 | contains 27 | 28 | subroutine foo_ufr(dtv, unit, iostat, iomsg) 29 | type(foo), intent(inout) :: dtv 30 | integer, intent(in) :: unit 31 | integer, intent(out) :: iostat 32 | character(*), intent(inout) :: iomsg 33 | read(unit) dtv%a, dtv%b 34 | end subroutine 35 | 36 | subroutine foo_ufw(dtv, unit, iostat, iomsg) 37 | type(foo), intent(in) :: dtv 38 | integer, intent(in) :: unit 39 | integer, intent(out) :: iostat 40 | character(*), intent(inout) :: iomsg 41 | write(unit) dtv%a, dtv%b 42 | end subroutine 43 | 44 | end module 45 | 46 | use foo_type 47 | integer :: lun 48 | type(foo) :: var = foo(1,2) 49 | open(newunit=lun,status='scratch',form='unformatted') 50 | write(lun) var 51 | rewind(lun) 52 | read(lun) var ! THIS LINE TRIGGERS THE ICE 53 | end 54 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180205a.f90: -------------------------------------------------------------------------------- 1 | !! SR100256. Fixed in 6.2 build 6212 2 | !! 3 | !! INTERNAL COMPILER ERROR -- PDT WITH PDT COMPONENT 4 | !! 5 | !! The following example triggers an internal error with NAG 6.2 6 | !! but compiles without error with 6.1. 7 | !! 8 | !! $ nagfor nag-20180205a.f90 9 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 10 | !! Panic: nag-20180205a.f90: LPP zero 11 | !! Internal Error -- please report this bug 12 | 13 | type :: foo(a) 14 | integer,len :: a 15 | end type 16 | type :: bar(b) 17 | integer,len :: b 18 | type(foo(2)) :: array(b) 19 | end type 20 | type(bar(1)) :: var 21 | end 22 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180205b.f90: -------------------------------------------------------------------------------- 1 | !! SR100256. Fixed in 6.2 build 6210. 2 | !! 3 | !! INTERNAL COMPILER ERROR -- PDT 4 | !! 5 | !! The following example triggers an internal error with NAG 6.2 6 | !! but compiles without error with 6.1. 7 | !! 8 | !! $ nagfor nag-20180205b.f90 9 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 10 | !! Panic: nag-20180205b.f90: NYI non-final len-varying comp 11 | !! Internal Error -- please report this bug 12 | 13 | type :: foo(len) 14 | integer,len :: len 15 | character(len) :: string 16 | integer :: array(len) 17 | end type 18 | type(foo(2)) :: x 19 | end 20 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180205c.f90: -------------------------------------------------------------------------------- 1 | !! SR100256. Fixed in 6.2 build 6207; 6.1 build 6148 2 | !! 3 | !! INTERNAL COMPILER ERROR -- EXTENSION OF PDT ALLOCATION 4 | !! 5 | !! The following example triggers an internal error with NAG 6.1 6 | !! 7 | !! $ nagfor nag-20180205c.f90 8 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6205 9 | !! Panic: nag-20180205c.f90: Missing dtp for kind? 10 | !! Internal Error -- please report this bug 11 | 12 | type :: foo(a,b) 13 | integer,kind :: a = 1 14 | integer,len :: b 15 | end type 16 | 17 | type, extends(foo) :: bar 18 | real, allocatable :: array(:) 19 | end type 20 | 21 | class(bar(b=:)), allocatable :: var 22 | allocate(bar(b=4) :: var) 23 | 24 | end 25 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180323.f90: -------------------------------------------------------------------------------- 1 | !! SR100272. Fixed in 6.2 build 6210; 6.1 build 6149. 2 | !! 3 | !! INVALID INTERMEDIATE C CODE (FINALIZATION) 4 | !! 5 | !! The NAG 6.1 and 6.2 compilers generate invalid intermediate C code for the 6 | !! following example. 7 | !! 8 | !! This is the same example and error as nag-20180201.f90 (SR99906, fixed in 6.1 9 | !! and 6.2) except that the ultimate variable X is a pointer, not allocatable. 10 | !! 11 | !! $ nagfor nag-20180323.f90 12 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6208 13 | !! Warning: nag-20180323.f90, line 36: Unused dummy variable THIS 14 | !! [NAG Fortran Compiler normal termination, 1 warning] 15 | !! nag-20180323.f90: In function 'main': 16 | !! nag-20180323.f90:41:11: error: 'x_' is a pointer; did you mean to use '->'? 17 | !! deallocate(x) 18 | !! ^ 19 | !! -> 20 | 21 | module outer_type 22 | type :: inner 23 | !integer, pointer :: foo => null() 24 | contains 25 | final :: delete 26 | end type 27 | type :: middle 28 | type(inner) :: scalar 29 | end type 30 | type :: outer 31 | type(middle) :: array(3) 32 | end type 33 | contains 34 | subroutine delete(this) 35 | type(inner), intent(inout) :: this 36 | !if (associated(this%foo)) deallocate(this%foo) 37 | end subroutine 38 | end module 39 | 40 | use outer_type 41 | type(outer), pointer :: x 42 | type(outer), allocatable :: y 43 | allocate(x) 44 | allocate(y) 45 | deallocate(x) 46 | deallocate(y) ! the nag-20180201.f90 bug 47 | end 48 | -------------------------------------------------------------------------------- /nag-bugs/nag-20180731.f90: -------------------------------------------------------------------------------- 1 | !! SR101681. Fixed in 6.2 build 6214. 2 | !! 3 | !! WRONG CODE WITH -nan 4 | !! 5 | !! With the -nan option the 6.2 compiler generates incorrect code for the 6 | !! following example. The print statement shows that the assignment of 0 7 | !! to the automatic array A is incomplete; only the (:,1) section is defined. 8 | !! 9 | !! The error is dependent on assigning an integer value rather than real, 10 | !! requiring type conversion, and on one of the array sizes being a parameter. 11 | !! 12 | !! $ nagfor -nan nag-20180731.f90 13 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6210 14 | !! [NAG Fortran Compiler normal termination] 15 | !! [nnc@arriba nag-bugs]$ ./a.out 16 | !! 0.0000000 0.0000000 NaN NaN NaN NaN 17 | 18 | integer, parameter :: n = 2 19 | integer :: m = 3 20 | call foo 21 | contains 22 | subroutine foo 23 | real :: a(n,m) 24 | a = 0 25 | print *, a 26 | end subroutine 27 | end 28 | -------------------------------------------------------------------------------- /nag-bugs/nag-20190302.f90: -------------------------------------------------------------------------------- 1 | !! SR103029: fixed in 6.2 build 6228 2 | !! 3 | !! TYPE BOUND CONTIGUOUS POINTER FUNCTION NOT RECOGNIZED AS CONTIGUOUS 4 | !! 5 | !! In this example the type bound function contig_res returns a simply 6 | !! contiguous array pointer. However when the function result is an actual 7 | !! argument for a contiguous dummy argument, the 6.2 compiler does not 8 | !! recognize it as simply contiguous. The example compiles fine with 6.1. 9 | !! 10 | !! For the error to occur: 1) the function needs to be type bound. No error 11 | !! if the function is not type bound; and 2) the dummy argument needs to be 12 | !! a pointer. No error if the dummy is not a pointer. 13 | !! 14 | !! $ nagfor -w nag-20190302.f90 15 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6227 16 | !! Error: nag-20190302.f90, line 33: Argument B (no. 1) of CONTIG_ARG is a CONTIGUOUS pointer, but the actual argument BAR%CONTIG_RES() is not simply contiguous 17 | !! 18 | 19 | module mod 20 | type :: foo 21 | contains 22 | procedure :: contig_res 23 | end type 24 | contains 25 | function contig_res(this) result(a) 26 | class(foo), intent(in) :: this 27 | real, pointer, contiguous :: a(:) 28 | allocate(a(10)) 29 | end function 30 | end module 31 | 32 | program main 33 | use mod 34 | type(foo) :: bar 35 | call contig_arg(bar%contig_res()) 36 | contains 37 | subroutine contig_arg(b) 38 | real, pointer, contiguous, intent(in) :: b(:) 39 | end subroutine 40 | end program 41 | -------------------------------------------------------------------------------- /nag-bugs/nag-20190507.f90: -------------------------------------------------------------------------------- 1 | !! SR103454: fixed in 6.2 build 6230 2 | !! 3 | !! WRONG RESULT FROM SOURCED ALLOCATION 4 | !! 5 | !! This is a pared down version of nag-20190506.f90. Note it also uses 6 | !! an integer value instead of a character, which highlights this problem 7 | !! is not specific to characters. 8 | !! 9 | !! The following example yields the incorrect result and exits abnormally 10 | !! at the 'STOP 1' statement. This is with NAG 6.2 (6228) and 6.1 (6149) 11 | !! 12 | 13 | type foo 14 | class(*), allocatable :: x 15 | end type 16 | type(foo) :: a, b 17 | 18 | allocate(b%x, source=foo(42)) ! THIS DOES NOT DEFINE B%X CORRECTLY 19 | !call set(b, 42) ! THIS DOES NOT DEFINE B%X CORRECTLY 20 | !a = foo(42); allocate(b%x, source=a) ! THIS WORKS 21 | !b = foo(foo(42)) ! THIS WORKS 22 | 23 | ! Is b%x%x == 42? 24 | select type (bx => b%x) 25 | type is (foo) 26 | select type (bxx => bx%x) 27 | type is (integer) 28 | if (bxx /= 42) stop 1 29 | class default 30 | stop 2 31 | end select 32 | class default 33 | stop 3 34 | end select 35 | 36 | contains 37 | 38 | subroutine set(f, c) 39 | type(foo), intent(out) :: f 40 | class(*), intent(in) :: c 41 | allocate(f%x, source=foo(c)) 42 | end subroutine 43 | 44 | end 45 | -------------------------------------------------------------------------------- /nag-bugs/nag-20190608.f90: -------------------------------------------------------------------------------- 1 | !! SR103620: Fixed in 6233 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! This is a regression somewhere between 6228 (okay) to 6232 (ICE) 6 | !! 7 | !! $ nagfor -c nag-20190608.f90 8 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6232 9 | !! Panic: nag-20190608.f90: Unexpected expr node type 432 10 | !! Internal Error -- please report this bug 11 | !! Abort 12 | !! 13 | 14 | module foo 15 | 16 | type :: ptr_box 17 | real, pointer :: ptr(:) => null() 18 | end type 19 | 20 | type :: struct 21 | type(ptr_box), allocatable :: array(:) 22 | end type 23 | 24 | contains 25 | 26 | subroutine bar(x, y) 27 | type(struct) :: x, y 28 | x%array(1)%ptr = y%array(1)%ptr 29 | end subroutine 30 | 31 | end module 32 | -------------------------------------------------------------------------------- /nag-bugs/nag-20190826a.f90: -------------------------------------------------------------------------------- 1 | !! SR104042: Fixed for 6.2 in build 6238. Still present in 6.1 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! $ nagfor -c nag-20190826a.f90 6 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6228 7 | !! Panic: nag-20190826a.f90: allocate_atmp cannot handle arbitrary non-constant shapes 8 | !! Internal Error -- please report this bug 9 | !! 10 | 11 | module example 12 | 13 | type :: foo(n) 14 | integer,len :: n 15 | integer :: array(0:n) 16 | end type 17 | type(foo(10)) :: x 18 | 19 | contains 20 | 21 | subroutine sub(x) 22 | type(foo(*)), intent(in) :: x 23 | real, allocatable :: array(:) 24 | array = pack(x%array, mask=(x%array/=0)) 25 | end subroutine 26 | 27 | end module 28 | -------------------------------------------------------------------------------- /nag-bugs/nag-20190826b.f90: -------------------------------------------------------------------------------- 1 | !! SR104042 2 | !! 3 | !! BAD C CODE GENERATED 4 | !! 5 | !! $ nagfor -c nag-20190826b.f90 6 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6228 7 | !! [NAG Fortran Compiler normal termination] 8 | !! nag-20190826b.f90: In function 'example_MP_sub': 9 | !! nag-20190826b.f90:17:32: error: 'x_Len' undeclared (first use in this function) 10 | !! subroutine sub 11 | !! ^ 12 | !! nag-20190826b.f90:17:32: note: each undeclared identifier is reported only once for each function it appears in 13 | !! 14 | 15 | module example 16 | 17 | contains 18 | 19 | subroutine sub 20 | 21 | type :: foo(n) 22 | integer,len :: n 23 | integer :: array(0:n) 24 | end type 25 | type(foo(10)) :: x 26 | namelist /nml/ x 27 | 28 | end subroutine 29 | 30 | end module 31 | -------------------------------------------------------------------------------- /nag-bugs/nag-20190831.f90: -------------------------------------------------------------------------------- 1 | !! SR104042: Fixed for 6.2 in build 6238. Still present in 6.1. 2 | !! 3 | !! WRONG RESULT FROM NORM2 WITH REAL64 ARRAY SECTION ARGUMENT 4 | !! 5 | !! The following example gives the wrong result for a real64 array, 6 | !! but the correct result for real32 (sqrt(2) rather than 2). Comparing 7 | !! the generated C code for the two cases suggests that the problem must 8 | !! be in the real64 version of the NORM2 library function. 9 | !! 10 | !! $ nagfor nag-20190831.f90 11 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6236 12 | !! [NAG Fortran Compiler normal termination] 13 | !! [nnc@noether nag-bugs]$ ./a.out 14 | !! STOP: 1 15 | !! 16 | 17 | double precision x(0:3,0:3) 18 | x = 1 19 | if (norm2(x(1:2,1:2)) /= 2) stop 1 ! WRONG NORM2 RESULT 20 | end 21 | -------------------------------------------------------------------------------- /nag-bugs/nag-20190906.f90: -------------------------------------------------------------------------------- 1 | !! SR104042: Fixed in 6.2 build 6239 2 | !! 3 | !! WRONG RESULT FROM NORM2 WITH REAL64 ARRAY SECTION ARGUMENT 4 | !! 5 | !! This is an alteration of nag-20190831.f90 which still fails after the 6 | !! fix in build 6238 for the latter test case. 7 | !! 8 | !! The following example norm2 should return sqrt(91) but instead returns 9 | !! sqrt(30) for a real64 array, but the correct result for real32. 10 | !! 11 | !! $ nagfor nag-20190906.f90 12 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6238 13 | !! [NAG Fortran Compiler normal termination] 14 | !! $ ./a.out 15 | !! STOP: 1 16 | !! 17 | 18 | double precision x(0:3,0:4) 19 | x = 0 20 | x(1:2,1:3) = reshape([1,2,3,4,5,6], shape=[2,3]) 21 | if (norm2(x(1:2,1:3)) /= sqrt(91.0d0)) stop 1 ! WRONG NORM2 RESULT 22 | end 23 | -------------------------------------------------------------------------------- /nag-bugs/nag-20200110.f90: -------------------------------------------------------------------------------- 1 | !! SR104737: Fixed in 6252 (6.2) and 7008 (7.0) 2 | !! 3 | !! WRONG CODE UNDER OPTIMIZATION 4 | !! 5 | !! The 6.2 compiler generates wrong code for the following example 6 | !! when compiled with -O. The array ARR2 should ultimately have the 7 | !! same size as ARR1, but instead has size 0. 8 | !! 9 | !! Credit to David Neill-Asanza (dhna@lanl.gov) for this reproducer. 10 | !! 11 | !! $ nagfor -O nag-20200110.f90 12 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6243 13 | !! 14 | !! $ ./a.out 15 | !! STOP: 1 16 | 17 | integer :: i, arr1(32) 18 | integer, allocatable :: arr2(:) 19 | arr1 = [(i, i=1,size(arr1))] 20 | arr2 = arr1 21 | arr2 = arr2 * 2 22 | if (size(arr2) /= size(arr1)) stop 1 23 | if (any(arr2 /= 2*arr1)) stop 2 24 | end 25 | 26 | -------------------------------------------------------------------------------- /nag-bugs/nag-20200124.f90: -------------------------------------------------------------------------------- 1 | !! SR104818: Fixed in 6.2-6224 and 7.0-7008 2 | !! 3 | !! GENERIC FUNCTION LOSES CONTIGUOUS ATTRIBUTE 4 | !! 5 | !! The following example shows that the CONTIGUOUS attribute of an 6 | !! array pointer valued function is not being propagated to the 7 | !! generic function for which it is a specific procedure in some 8 | !! contexts. The error occurs for both 6.2 and 7.0, but not 6.1 9 | !! 10 | !! $ nagfor -w nag-20200124.f90 11 | !! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6253 12 | !! Error: nag-20200124.f90, line 34: Argument DP (no. 1) of FOO is a CONTIGUOUS 13 | !! pointer, but the actual argument is not simply contiguous 14 | !! [NAG Fortran Compiler error termination, 1 error, 1 warning] 15 | !! 16 | 17 | module contig_generic_ptr_func 18 | 19 | interface dataptr 20 | procedure dataptr1 21 | end interface 22 | 23 | contains 24 | 25 | function dataptr1() result(dp) 26 | real, pointer, contiguous :: dp(:) 27 | allocate(dp(10)) 28 | end function 29 | 30 | end module 31 | 32 | use contig_generic_ptr_func 33 | real, pointer, contiguous :: x(:) 34 | x => dataptr() ! NO ERROR HERE 35 | call foo(dataptr1()) ! NO ERROR HERE 36 | call foo(dataptr()) ! BUT ERROR HERE 37 | contains 38 | subroutine foo(dp) 39 | real, pointer, contiguous :: dp(:) 40 | end subroutine 41 | end 42 | -------------------------------------------------------------------------------- /nag-bugs/nag-20220103.f90: -------------------------------------------------------------------------------- 1 | !! Fixed in 7.1 build 7106 2 | !! 3 | !! COMPILER REJECTS VALID CODE 4 | !! 5 | !! In the following example the derived type FOO is imported into the parent 6 | !! scope of the BLOCK construct, and is accessible from within the BLOCK 7 | !! construct as it should be. However its defined constructor seems to not 8 | !! be visible within the BLOCK construct because the compiler appears to be 9 | !! falling back to the intrinsic constructor. 10 | !! 11 | !! This error occurs with version 7.1, but compiles fine with 7.0. 12 | !! 13 | !! nagfor -w=all nag-20220103.f90 14 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7101 15 | !! Error: nag-20220103.f90, line 46: Constructor for type FOO has value for PRIVATE component PRIVATE_VAR 16 | !! [NAG Fortran Compiler error termination, 1 error] 17 | !! 18 | 19 | module foo_type 20 | 21 | implicit none 22 | private 23 | 24 | type, public :: foo 25 | private 26 | integer :: private_var 27 | end type 28 | 29 | ! Defined constructor 30 | interface foo 31 | procedure my_foo_constructor 32 | end interface 33 | 34 | contains 35 | 36 | function my_foo_constructor(m) result(f) 37 | integer, intent(in) :: m 38 | type(foo) :: f 39 | f%private_var = m 40 | end function 41 | 42 | end module 43 | 44 | program example 45 | use foo_type 46 | block ! foo's defined constructor not visible in this block 47 | type(foo) :: f 48 | f = foo(42) 49 | end block 50 | end 51 | 52 | -------------------------------------------------------------------------------- /nag-bugs/nag-20220104.f90: -------------------------------------------------------------------------------- 1 | !! SR108547: fixed in 7.1 build 7106 2 | !! 3 | !! COMPILER REJECTS VALID CODE 4 | !! 5 | !! The compiler issues a strange error for this example: "Cannot set attribute 6 | !! for derived type name EVENT". This appears to be connected to a reference 7 | !! to the default constructor expression EVENT() in the CALL statement, which 8 | !! is contained in a BLOCK construct. The example compiles without error if 9 | !! the CALL is not contained in a BLOCK construct. This is a regression in 7.1; 10 | !! the example compiles fine with 7.0. 11 | !! 12 | !! $ nagfor -c -w=all bug.f90 13 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7105 14 | !! Error: bug.f90, line 27: Cannot set attribute for derived type name EVENT 15 | !! detected at SUBROUTINE@ 16 | !! [NAG Fortran Compiler pass 1 error termination, 1 error, 1 warning] 17 | 18 | module example 19 | 20 | type :: event 21 | end type 22 | 23 | contains 24 | 25 | subroutine foo 26 | block 27 | call bar(event()) 28 | end block 29 | end subroutine 30 | 31 | subroutine bar(e) 32 | class(event), intent(in) :: e 33 | end subroutine 34 | 35 | end module 36 | -------------------------------------------------------------------------------- /nag-bugs/nag-20220117.f90: -------------------------------------------------------------------------------- 1 | !! SR108297: fixed in 7.1 build 7103 2 | !! 3 | !! INVALID INTERMEDIATE C CODE 4 | !! 5 | !! The NAG 7.1 compiler generates invalid intermediate C code for 6 | !! the intrinsic CO_BROADCAST subroutine below. 7 | !! 8 | !! $ nagfor -coarray -f2018 nag-20220117.f90 9 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7102 10 | !! nag-20220117.f90: In function 'MAIN': 11 | !! nag-20220117.f90:15:142: error: '__NAGf90_CoDope2' has no member named 'dim' 12 | !! 4 | call co_broadcast(bsize, 1) 13 | 14 | integer, allocatable :: bsize(:)[:] 15 | allocate(bsize(5)[*]) 16 | if (this_image() == 1) bsize(:)[1] = 1 17 | call co_broadcast(bsize, 1) 18 | end 19 | -------------------------------------------------------------------------------- /nag-bugs/nag-20220127.f90: -------------------------------------------------------------------------------- 1 | !! SR108353: fixed in 7.1 build 7106 2 | !! 3 | !! INVALID INTERMEDIATE C CODE 4 | !! 5 | !! The NAG 7.1 compiler generates invalid intermediate C code for 6 | !! the internal subroutine in this example. 7 | !! 8 | !! $ nagfor -coarray nag-20220127.f90 9 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7103 10 | !! [NAG Fortran Compiler normal termination] 11 | !! nag-20220127.f90: In function 'example_IP_sub': 12 | !! nag-20220127.f90:34:12: error: invalid type argument of '->' (have '__NAGf90_CoDope1') 13 | !! 34 | end subroutine 14 | !! | ^~ 15 | !! nag-20220127.f90:34:35: error: invalid type argument of '->' (have '__NAGf90_CoDope1') 16 | !! 34 | end subroutine 17 | !! | ^ 18 | !! nag-20220127.f90:34:56: error: invalid type argument of '->' (have '__NAGf90_CoDope1') 19 | !! 34 | end subroutine 20 | !! | ^ 21 | !! nag-20220127.f90:34:8: error: invalid type argument of '->' (have '__NAGf90_CoDope1') 22 | !! 34 | end subroutine 23 | !! | ^~ 24 | 25 | program example 26 | call sub([1,2]) 27 | contains 28 | subroutine sub(array) 29 | integer, intent(in) :: array(:) 30 | type :: box 31 | integer, allocatable :: array(:) 32 | end type 33 | type(box), allocatable :: buffer[:] 34 | allocate(buffer[*]) 35 | buffer%array = array 36 | end subroutine 37 | end program 38 | -------------------------------------------------------------------------------- /nag-bugs/nag-20220312.f90: -------------------------------------------------------------------------------- 1 | !! SR108549: fixed in 7.1 build 7106 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! $ nagfor -c -f2018 nag-20220312.f90 6 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7105 7 | !! Panic: nag-20220312.f90: Not a Uindex 8 | !! Internal Error -- please report this bug 9 | !! Abort 10 | 11 | module mpi_f08 ! Essential bit copied from MPICH 4.0 and stripped down 12 | interface MPI_Bcast 13 | subroutine mpi_bcast_f08ts(buffer) 14 | type(*), dimension(..), intent(inout) :: buffer 15 | end subroutine 16 | end interface 17 | end module 18 | 19 | use mpi_f08 20 | contains 21 | subroutine bcast_char_0(scalar) 22 | character(*), intent(inout) :: scalar 23 | call MPI_Bcast(scalar) 24 | end subroutine 25 | end 26 | -------------------------------------------------------------------------------- /nag-bugs/nag-20230426.f90: -------------------------------------------------------------------------------- 1 | !! SR109734: Fixed in 7125 2 | !! 3 | !! INVALID INTERMEDIATE C CODE 4 | !! 5 | !! This example produces invalid intermediate C code for the allocation 6 | !! of a PDT array pointer when compiled with -nan. 7 | !! 8 | !! $ nagfor -O0 -nan nag-20230426.f90 9 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7124 10 | !! [NAG Fortran Compiler normal termination, 1 warning] 11 | !! nag-20230426.f90: In function 'MAINIP_foo': 12 | !! nag-20230426.f90:26:12: error: incompatible types when assigning to type 13 | !! '__NAGf90_Dope1' from type '__NAGf90_PDTDope1' 14 | !! 9 | allocate(pdt(3)::u(5)) 15 | !! | ^ 16 | !! 17 | 18 | type pdt(n) 19 | integer,len :: n 20 | real :: x(n) 21 | end type 22 | type(pdt(:)), pointer :: a(:) 23 | call foo(a) 24 | contains 25 | subroutine foo(u) 26 | type(pdt(:)), pointer :: u(:) 27 | allocate(pdt(3)::u(5)) 28 | end subroutine 29 | end 30 | -------------------------------------------------------------------------------- /nag-bugs/nag-20230426b.f90: -------------------------------------------------------------------------------- 1 | !! SR109729: Fixed in 7125 2 | !! 3 | !! INVALID INTERMEDIATE C CODE 4 | !! 5 | !! This example produces invalid intermediate C code for the assignment 6 | !! of a scalar PDT variable to an element of an allocated PDT array with 7 | !! the same length-type parameter. 8 | !! 9 | !! $ nagfor -O0 nag-20230426b.f90 10 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7124 11 | !! 12 | !! Warning: nag-20230426b.f90, line 12: Variable B referenced but never set 13 | !! [NAG Fortran Compiler normal termination, 1 warning] 14 | !! nag-20230426b.f90: In function 'MAIN': 15 | !! nag-20230426b.f90:27:89: error: incompatible types when assigning to type 16 | !! 'struct _PDT_UNKNOWNLEN_MAINDT_pdt' from type 'struct _PDT_3_MAINDT_pdt' 17 | !! 10 | a(1) = b 18 | !! | ^ 19 | 20 | type pdt(n) 21 | integer,len :: n 22 | real :: x(n) 23 | end type 24 | 25 | type(pdt(:)), allocatable :: a(:) 26 | type(pdt(3)) :: b 27 | 28 | allocate(pdt(3) :: a(2)) 29 | a(1) = b 30 | 31 | end 32 | -------------------------------------------------------------------------------- /nag-bugs/nag-20230527.f90: -------------------------------------------------------------------------------- 1 | !! SR109822: Fixed in 7129 2 | !! 3 | !! INVALID INTERMEDIATE C CODE 4 | !! 5 | !! This example produces invalid intermediate C code when accessing the 6 | !! length parameter of a parameterized polymorphic variable. 7 | !! 8 | !! $ nagfor nag-20230527.f90 9 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7127 10 | !! 11 | !! nag-20230527.f90: In function 'mfe_disc_type_MP_init': 12 | !! nag-20230527.f90:45:11: error: 'this_' is a pointer; did you mean to use '->'? 13 | !! 36 | n = this%p%npde 14 | !! | ^ 15 | !! | -> 16 | 17 | module pde_class 18 | type, abstract :: pde(npde) 19 | integer,len :: npde 20 | end type 21 | end module 22 | 23 | module navier_stokes_type 24 | use pde_class 25 | type, extends(pde) :: navier_stokes 26 | end type 27 | contains 28 | subroutine alloc_navier_stokes(p) 29 | class(pde(:)), allocatable :: p 30 | allocate(navier_stokes(npde=3) :: p) 31 | end subroutine 32 | end module 33 | 34 | module mfe_disc_type 35 | use pde_class 36 | type :: foo 37 | class(pde(:)), allocatable :: p 38 | contains 39 | procedure :: init 40 | end type 41 | contains 42 | subroutine init(this) 43 | use navier_stokes_type 44 | class(foo), intent(out) :: this 45 | integer :: n 46 | call alloc_navier_stokes(this%p) 47 | n = this%p%npde 48 | end subroutine 49 | end module 50 | 51 | program main 52 | use mfe_disc_type 53 | type(foo) :: x 54 | call x%init 55 | if (x%p%npde /= 3) error stop 56 | end program 57 | 58 | -------------------------------------------------------------------------------- /nag-bugs/nag-20230529.f90: -------------------------------------------------------------------------------- 1 | !! SR109818: Fixed in 7129 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! The following example involving coarray derived type components as 6 | !! selectors in an associate construct triggers an ICE with NAG 7.1.7127 7 | !! 8 | !! $ nagfor -c -coarray nag-20230529.f90 9 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7127 10 | !! Panic: nag-20230529.f90: Uindex type 7 is not Symptr 11 | !! Internal Error -- please report this bug 12 | !! 13 | 14 | module example 15 | type :: foo 16 | real, allocatable :: co_tmp1[:], co_tmp2[:] 17 | end type 18 | contains 19 | subroutine bar(this) 20 | type(foo) :: this 21 | real :: x 22 | associate (a => this%co_tmp1, b => this%co_tmp2) 23 | if (this_image() < num_images()) then 24 | x = a[this_image()+1] 25 | b = x 26 | end if 27 | end associate 28 | end subroutine 29 | end module 30 | -------------------------------------------------------------------------------- /nag-bugs/nag-20230603a.f90: -------------------------------------------------------------------------------- 1 | !! SR109840: fixed in 7.1.30 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! The following example triggers an ICE with nagfor version 7.1.29 6 | !! 7 | !! $ nagfor -coarray -num_images=2 bug.f90 8 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7129 9 | !! Panic: bug.f90: mkarraydesc unexpected node type 562 10 | !! Internal Error -- please report this bug 11 | !! 12 | !! This works fine if A has rank 0 or 1 instead of 2 13 | !! 14 | 15 | real :: a(2,2)[*] 16 | a = 1.0 17 | sync all 18 | if (this_image() < num_images()) print *, a(:,:)[this_image()+1] 19 | end 20 | -------------------------------------------------------------------------------- /nag-bugs/nag-20230603b.f90: -------------------------------------------------------------------------------- 1 | !! SR109841: fixed in 7.1.30 2 | !! 3 | !! BAD LOCAL COPY OF COINDEXED OBJECT ACTUAL ARGUMENT 4 | !! 5 | !! In the following example a multirank coindexed object is an actual 6 | !! argument in a subroutine call. It appears that a local copy of it 7 | !! is being made and the copy actually passed to the subroutine. 8 | !! This example shows that the copy is not being correctly intialized. 9 | !! 10 | !! $ nagfor -coarray -num_images=2 nag-20230603b.f90 11 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7129 12 | !! 13 | !! $ ./a.out 14 | !! received 1.0 2.0 1.0 2.0 15 | !! expected 1.0 2.0 3.0 4.0 16 | !! ERROR STOP 17 | 18 | module mod 19 | implicit none 20 | contains 21 | subroutine sub1 22 | real, allocatable :: a(:,:)[:] 23 | allocate(a(2,2)[*]) 24 | a = reshape([1,2,3,4], shape=[2,2]) ! all images get the same value 25 | sync all 26 | if (this_image() == 1) call sub2(a, a(:,:)[2]) 27 | end subroutine 28 | subroutine sub2(x, y) 29 | real, intent(in) :: x(:,:), y(:,:) 30 | write(*,'(a,4f5.1)') 'received', y 31 | write(*,'(a,4f5.1)') 'expected', x 32 | if (any(x /= y)) error stop 33 | end subroutine 34 | end module 35 | use mod 36 | call sub1 37 | end 38 | -------------------------------------------------------------------------------- /nag-bugs/nag-20230603c.f90: -------------------------------------------------------------------------------- 1 | !! SR109842: fixed in 7.1.30 2 | !! 3 | !! BAD RESULTS ACCESSING MULTIRANK COARRAY DUMMY ON OTHER IMAGES 4 | !! 5 | !! In the following example a multirank coarray is an actual argument for a 6 | !! coarray dummy. Accessing the value of the dummy on other images either 7 | !! yields the incorrect values or will occasionally segfault. 8 | !! 9 | !! $ nagfor -coarray -num_images=2 nag-202306c.f90 10 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7129 11 | !! 12 | !! $ ./a.out 13 | !! expected 1.0 2.0 3.0 4.0 14 | !! obtained 1.0 2.0 1.0 2.0 15 | !! ERROR STOP 16 | !! 17 | 18 | module mod 19 | implicit none 20 | contains 21 | subroutine sub1 22 | real, allocatable :: w(:,:)[:] 23 | allocate(w(2,2)[*]) 24 | w = reshape([1,2,3,4], shape=[2,2]) ! all images get the same value 25 | sync all 26 | call sub2(w) ! PASS COARRAY 27 | end subroutine 28 | subroutine sub2(v) 29 | real, intent(inout) :: v(:,:)[*] 30 | real :: tmp(2,2) 31 | if (this_image() < num_images()) then 32 | write(*,'(a,4f5.1)') 'expected', v 33 | write(*,'(a,4f5.1)') 'obtained', v(:,:)[this_image()+1] ! BAD VALUES 34 | !tmp = v(:,:)[this_image()+1] ! SAME HERE 35 | !write(*,'(a,4f5.1)') 'obtained', tmp 36 | if (any(v /= v(:,:)[this_image()+1])) error stop 37 | end if 38 | sync all 39 | end subroutine 40 | end module 41 | use mod 42 | call sub1 43 | end 44 | -------------------------------------------------------------------------------- /nag-bugs/nag-20231204.f90: -------------------------------------------------------------------------------- 1 | !! SR110428. Fixed in 7144 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! $ nagfor -c nag-20231204.f90 6 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7141 7 | !! Panic: nag-20231204.f90: not pp? 8 | !! Internal Error -- please report this bug 9 | !! Abort 10 | 11 | module parameter_entry_class 12 | 13 | type, abstract :: parameter_entry 14 | contains 15 | procedure :: copy 16 | generic :: assignment(=) => copy 17 | procedure(copy), deferred :: copy_ 18 | end type 19 | 20 | type, extends(parameter_entry) :: any_scalar 21 | class(*), allocatable :: value 22 | contains 23 | procedure :: copy_ => any_scalar_copy 24 | end type 25 | 26 | contains 27 | 28 | subroutine copy(lhs, rhs) 29 | class(parameter_entry), intent(inout) :: lhs 30 | class(parameter_entry), intent(in) :: rhs 31 | if (same_type_as(lhs, rhs)) then 32 | call lhs%copy_(rhs) 33 | else 34 | error stop 35 | end if 36 | end subroutine 37 | 38 | subroutine any_scalar_copy(lhs, rhs) 39 | class(any_scalar), intent(inout) :: lhs 40 | class(parameter_entry), intent(in) :: rhs 41 | select type (rhs) 42 | type is (any_scalar) 43 | lhs%value = rhs%value 44 | end select 45 | end subroutine 46 | 47 | end module 48 | -------------------------------------------------------------------------------- /nag-bugs/nag-20231211.f90: -------------------------------------------------------------------------------- 1 | !! SR110461. Fixed in 7142. 2 | !! 3 | !! INTERNAL COMPILER ERROR 4 | !! 5 | !! $ nagfor nag-20231211.f90 6 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7141 7 | !! Panic: nag-20231211.f90: Not a Uindex 8 | !! Internal Error -- please report this bug 9 | 10 | module mod 11 | type :: any_vector 12 | class(*), allocatable :: value(:) 13 | contains 14 | procedure :: value_ptr 15 | end type 16 | contains 17 | function value_ptr(this) 18 | class(any_vector), intent(in), target :: this 19 | class(*), pointer :: value_ptr(:) 20 | value_ptr => this%value 21 | end function 22 | end module 23 | 24 | use mod 25 | type(any_vector), pointer :: a 26 | class(*), allocatable :: y(:) 27 | allocate(a) 28 | allocate(a%value, source=[1,2]) 29 | y = a%value_ptr() 30 | end 31 | -------------------------------------------------------------------------------- /nag-bugs/nag-20231213.f90: -------------------------------------------------------------------------------- 1 | !! SR 110467. Fixed in 7143. 2 | !! 3 | !! BAD CODE WITH ASSUMED RANK, CLASS(*) ARGUMENT 4 | !! 5 | !! The following example variously produces a runtime buffer overflow error, 6 | !! segmentation error, or incorrect empty string "" from the write statement 7 | !! in the WRITE_CSTAR procedure. Essential characteristics seem to be that 8 | !! the argument is unlimited polymorphic, assumed rank, with character 9 | !! dynamic type. Note that problem is not specific to the scalar (rank 0) 10 | !! case -- the same thing happens with an array argument. 11 | !! 12 | !! $ nagfor -f2018 nag-20231213.f90 13 | !! NAG Fortran Compiler Release 7.1(Hanzomon) Build 7141 14 | !! 15 | !! $ ./a.out 16 | !! expected:fubar 17 | !! Runtime Error: nag-20231213.f90, line 37: Buffer overflow on output 18 | !! Program terminated by I/O error on unit 6 (Output_Unit,Formatted,Sequential) 19 | !! Aborted (core dumped) 20 | 21 | program main 22 | 23 | class(*), allocatable :: a 24 | allocate(a, source='fubar') 25 | select type (a) 26 | type is (character(*)) 27 | write(*,'(*(a))') 'expected:', a 28 | end select 29 | call write_cstar(a) 30 | 31 | contains 32 | 33 | subroutine write_cstar(x) 34 | class(*), intent(in) :: x(..) 35 | select rank (x) 36 | rank (0) 37 | select type (x) 38 | type is (character(*)) 39 | write(*,'(*(a))') 'write_cstar:', x ! ERROR HERE 40 | end select 41 | end select 42 | end subroutine 43 | 44 | end program 45 | -------------------------------------------------------------------------------- /nag-bugs/nag-20241130.f90: -------------------------------------------------------------------------------- 1 | !! SR111677. Fixed in 7.2.7221 2 | !! COMPILER HANGS 3 | !! 4 | !! nagfor 7.2.7220 hangs on the following code. If either of 5 | !! the associations is removed the code compiles fine; only 6 | !! when both are present does it hang. 7 | 8 | subroutine hang(E, index) 9 | complex :: E(:) 10 | integer :: index(:) 11 | associate (E_re => E(index)%re, E_im => E(index)%im) 12 | end associate 13 | end subroutine 14 | -------------------------------------------------------------------------------- /nag-bugs/nag-20250124.f90: -------------------------------------------------------------------------------- 1 | !! SR111801: Fixed in 7225 2 | !! INVALID INTERMEDIATE C CODE WITH GCC 14 3 | !! 4 | !! The following example gives a C compiler error with nagfor 7.2.7221 and 5 | !! gcc 14.2, but compiles fine with gcc 13 and earlier. The error can be 6 | !! avoided using the nagfor option '-Wc,-Wno-incompatible-pointer-types' 7 | !! to have gcc downgrade the error to a warning. 8 | !! 9 | !! $ nagfor -c nag-20250124.f90 10 | !! NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7221 11 | !! [NAG Fortran Compiler normal termination] 12 | !! nag-20250124.f90: In function 'foo_': 13 | !! nag-20250124.f90:28:6: error: assignment to 'float (*)(float)' from incompatible pointer type 'float (*)()' [-Wincompatible-pointer-types] 14 | !! 28 | call c_f_procpointer(funptr, fptr) 15 | !! | ^ 16 | 17 | subroutine foo 18 | 19 | use,intrinsic :: iso_c_binding, only: c_funptr, c_f_procpointer 20 | 21 | abstract interface 22 | real function f(x) bind(c) 23 | real, value :: x 24 | end function 25 | end interface 26 | procedure(f), pointer :: fptr 27 | type(c_funptr) :: funptr 28 | 29 | call c_f_procpointer(funptr, fptr) 30 | 31 | end subroutine 32 | -------------------------------------------------------------------------------- /pgi-bugs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | 3 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake") 4 | include(testing) 5 | 6 | project(pgi-bugs Fortran) 7 | 8 | add_compiler_test(SOURCES pgi-20180320.f90 RUN_ONLY LABELS FIXED) 9 | 10 | add_compiler_test(SOURCES pgi-20180505a.f90 RUN_ONLY) 11 | add_compiler_test(SOURCES pgi-20180505b.f90 COMPILE_ONLY LABELS FIXED) 12 | add_compiler_test(SOURCES pgi-20180505c.f90 COMPILE_ONLY) 13 | 14 | add_compiler_test(SOURCES pgi-bitfun-kind.f90 COMPILE_ONLY) 15 | 16 | add_compiler_test(SOURCES pgi-constructor-1.f90 COMPILE_ONLY LABELS FIXED) 17 | 18 | add_compiler_test(SOURCES pgi-dflt-init-1.f90 COMPILE_ONLY LABELS FIXED) 19 | add_compiler_test(SOURCES pgi-dflt-init-2.f90 COMPILE_ONLY LABELS FIXED) 20 | 21 | add_compiler_test(SOURCES pgi-dt-asn-1.f90 RUN_ONLY) 22 | 23 | add_compiler_test(SOURCES pgi-src-alloc-2.f90 RUN_ONLY LABELS FIXED) 24 | add_compiler_test(SOURCES pgi-src-alloc-3.f90 RUN_ONLY 25 | COMPILE_FLAGS "-g") 26 | 27 | add_compiler_test(SOURCES pgi-ptr-rank-remap-1.f90 RUN_ONLY) 28 | add_compiler_test(SOURCES pgi-ptr-rank-remap-2.f90 RUN_ONLY) 29 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-20180320.f90: -------------------------------------------------------------------------------- 1 | !! 2 | !! MOVE_ALLOC WITH POLYMORPHIC ARGUMENTS LOSES DYNAMIC TYPE 3 | !! 4 | !! Incorrect results with 15.10, 16.10, 17.10, and 18.1 5 | !! Fixed in 18.10 6 | !! 7 | !! Originates from https://github.com/nncarlson/yajl-fort/blob/master/src/json.F90 8 | !! 9 | !! $ pgfortran --version 10 | !! pgfortran 18.1-1 64-bit target on x86-64 Linux -tp haswell 11 | !! 12 | !! $ pgfortran pgi-20180320.f90 13 | !! sn-fey1.lanl.gov> ./a.out 14 | !! wrong type after move_alloc 15 | !! 2 16 | !! 17 | 18 | type, abstract :: json_value 19 | end type 20 | 21 | type, extends(json_value) :: json_integer 22 | integer :: value 23 | end type 24 | 25 | type :: json_builder 26 | class(json_value), allocatable :: result 27 | end type 28 | 29 | class(json_value), allocatable :: val 30 | 31 | call sub(val) 32 | 33 | contains 34 | 35 | subroutine sub(value) 36 | 37 | class(json_value), allocatable, intent(out) :: value 38 | type(json_builder) :: builder 39 | 40 | allocate(builder%result, source=json_integer(42)) 41 | select type (result => builder%result) 42 | type is (json_integer) 43 | class default 44 | stop 1 45 | end select 46 | 47 | call move_alloc(builder%result, value) 48 | 49 | select type (value) 50 | type is (json_integer) 51 | class default 52 | print *, 'wrong type after move_alloc' 53 | stop 2 54 | end select 55 | 56 | end subroutine 57 | 58 | end 59 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-20180505b.f90: -------------------------------------------------------------------------------- 1 | !! INTERNAL COMPILER ERROR 2 | !! 3 | !! Fixed in 18.10 4 | !! 5 | !! $ pgfortran --version 6 | !! pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 7 | !! $ pgfortran pgi-20180505b.f90 8 | !! PGF90-F-0000-Internal compiler error. insert_sym: bad hash 639 (pgi-20180505b.f90: 14) 9 | !! PGF90/x86-64 Linux 18.4-0: compilation aborted 10 | 11 | character(3), target :: a = 'foo' 12 | contains 13 | function ptr() 14 | class(*), pointer :: ptr 15 | ptr => a 16 | select type (ptr) 17 | type is (character(*)) 18 | end select 19 | end function 20 | end 21 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-20180505c.f90: -------------------------------------------------------------------------------- 1 | !! INTERNAL COMPILER ERROR 2 | !! 3 | !! $ pgfortran --version 4 | !! pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 5 | !! $ pgfortran -c pgi-20180505c.f90 6 | !! PGF90-S-0000-Internal compiler error. size_of: attempt to get size of assumed size character 0 (pgi-20180505c.f90: 4) 7 | !! 0 inform, 0 warnings, 1 severes, 0 fatal for sub 8 | 9 | subroutine sub(array) 10 | character(*), intent(in) :: array(:) 11 | class(*), allocatable :: copy(:) 12 | allocate(copy, source=array) 13 | end 14 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-bitfun-kind.f90: -------------------------------------------------------------------------------- 1 | !! BIT FUNCTIONS RETURN WRONG KIND FOR INT8 ARGUMENTS 2 | !! 3 | !! This program should compile without error. 4 | 5 | program main 6 | 7 | use,intrinsic :: iso_fortran_env 8 | 9 | call int8_arg(iand(1_int8,1_int8)) 10 | call int8_arg(ibset(1_int8,1)) 11 | call int8_arg(ieor(1_int8,1_int8)) 12 | call int8_arg(ior(1_int8,1_int8)) 13 | call int8_arg(ishft(1_int8,1)) 14 | call int8_arg(not(1_int8)) 15 | 16 | contains 17 | 18 | subroutine int8_arg(n) 19 | integer(int8) :: n 20 | end subroutine 21 | 22 | end program 23 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-constructor-1.f90: -------------------------------------------------------------------------------- 1 | !! VALID STRUCTURE CONSTRUCTOR REJECTED 2 | !! 3 | !! Fixed in 18.10 4 | !! 5 | !! Structure constructor with allocatable component 6 | !! 7 | !! $ pgfortran pgi-constructor-1.f90 8 | !! PGF90-F-0155-No default initialization in structure constructor- member val$td (pgi-constructor-1.f90: 11) 9 | !! PGF90/x86-64 Linux 18.4-0: compilation aborted 10 | 11 | type foo 12 | class(*), allocatable :: val 13 | end type 14 | type(foo) :: x 15 | x = foo(42) 16 | end 17 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-dflt-init-1.f90: -------------------------------------------------------------------------------- 1 | !! ICE WITH DEFAULT INITIALIZATION OF DT COMPONENT 2 | !! 3 | !! Fixed in 18.10 4 | !! 5 | !! $ pgfortran --version 6 | !! pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 7 | !! $ pgfortran pgi-dflt-init-1.f90 8 | !! PGF90-S-0000-Internal compiler error. dinits:bad dt 54 (pgi-dflt-init-1.f90: 19) 9 | !! PGF90-S-0000-Internal compiler error. assem.c-put_skip old,new not in sync 16 (pgi-dflt-init-1.f90: 19) 10 | !! 0 inform, 0 warnings, 2 severes, 0 fatal for map_type 11 | 12 | module map_type 13 | type :: item 14 | type(item), pointer :: next => null(), prev => null() 15 | end type 16 | type :: map 17 | type(item), pointer :: first => null() 18 | end type 19 | type :: parameter_list 20 | type(map) :: params = map() ! this default initializaton causes the ICE 21 | end type 22 | end module 23 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-dflt-init-2.f90: -------------------------------------------------------------------------------- 1 | !! DEFAULT INITIALIZATION WITH VALID EMPTY CONSTRUCTOR REJECTED 2 | !! 3 | !! Fixed in 18.10 4 | !! 5 | !! This adds a final procedure for ITEM to pgi-dflt-init-1.f90 6 | !! 7 | !! $ pgfortran --version 8 | !! pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 9 | !! $ pgfortran pgi-dflt-init-2.f90 10 | !! PGF90-F-0155-Empty structure constructor() - type map (pgi-dflt-init-2.f90: 21) 11 | !! PGF90/x86-64 Linux 18.4-0: compilation aborted 12 | 13 | module map_type 14 | type :: item 15 | type(item), pointer :: next => null(), prev => null() 16 | contains 17 | final :: item_delete 18 | end type 19 | type :: map 20 | type(item), pointer :: first => null() 21 | end type 22 | type :: parameter_list 23 | type(map) :: params = map() ! VALID EMPTY CONSTRUCTOR REJECTED BY PGFORTRAN 24 | end type 25 | contains 26 | subroutine item_delete(this) 27 | type(item), intent(inout) :: this 28 | end subroutine 29 | end module 30 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-dt-asn-1.f90: -------------------------------------------------------------------------------- 1 | !! BAD INTRINSIC ASSIGNMENT OF DT WITH CLASS(*) ALLOCATABLE COMPONENT 2 | !! 3 | !! Program should exit without output. 4 | !! 5 | !! $ pgfortran --version 6 | !! pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 7 | !! 8 | !! $ pgfortran pgi-dt-asn-1.f90 9 | !! $ ./a.out 10 | !! 22 11 | 12 | type foo 13 | class(*), allocatable :: val 14 | end type 15 | type(foo) :: x, y 16 | 17 | allocate(x%val, source=42) 18 | if (.not.allocated(x%val)) stop 11 19 | select type (val => x%val) 20 | type is (integer) 21 | if (val /= 42) stop 12 22 | class default 23 | stop 13 24 | end select 25 | 26 | y = x ! THIS INTRINSIC ASSIGNMENT IS NOT EXECUTED CORRECTLY 27 | if (.not.allocated(y%val)) stop 21 28 | select type (val => y%val) 29 | type is (integer) 30 | if (val /= 42) stop 22 ! EXITS HERE 31 | class default 32 | stop 23 33 | end select 34 | end 35 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-ptr-rank-remap-1.f90: -------------------------------------------------------------------------------- 1 | !! DEFERRED LENGTH PARAMETER NOT COPIED IN POINTER RANK REMAPPING 2 | !! 3 | !! In the following example, the pointer assignment involving rank remapping 4 | !! does not properly define the deferred length parameter of the pointer object 5 | !! (see F2008 5.3.14 #3). Key to the error is that the target is a 6 | !! deferred-length allocatable 7 | !! 8 | !! $ pgfortran --version 9 | !! pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 10 | !! $ pgfortran pgi-ptr-rank-remap-1.f90 11 | !! $ ./a.out 12 | !! len=65538 (expect 3) 13 | !! 1 14 | 15 | character(:), allocatable, target :: array(:) 16 | character(:), pointer :: ptr(:,:) 17 | allocate(array(1), source=['foo']) 18 | ptr(1:1,1:1) => array ! THIS IS NOT DONE CORRECTLY 19 | print '(a,2(i0,a))', 'len=', len(ptr), ' (expect ', len(array), ')' 20 | if (len(ptr) /= len(array)) stop 1 21 | end 22 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-ptr-rank-remap-2.f90: -------------------------------------------------------------------------------- 1 | !! BAD ARRAY BOUNDS WITH CLASS(*) POINTER RANK REMAPPING 2 | !! 3 | !! PGI seems to be completely broken when it comes to pointer 4 | !! rank remapping for CLASS(*) objects. 5 | !! 6 | !! Expected output: 7 | !! lbound=1 1, ubound=2 2, shape=2 2 8 | !! 9 | !! pgfortran output: 10 | !! $ pgfortran --version 11 | !! pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 12 | !! $ pgfortran pgi-ptr-rank-remap-2.f90 13 | !! $ ./a.out 14 | !! lbound=1 0, ubound=4 0, shape=4 -65536 15 | !! 1 16 | 17 | class(*), allocatable, target :: array(:) 18 | class(*), pointer :: p(:,:) 19 | allocate(array, source=[1,2,3,4]) 20 | p(1:2,1:2) => array 21 | print '(3(a,i0,1x,i0))', 'lbound=', lbound(p), ', ubound=', ubound(p), ', shape=', shape(p) 22 | if (any(lbound(p) /= 1 .or. ubound(p) /= 2)) stop 1 23 | end 24 | -------------------------------------------------------------------------------- /pgi-bugs/pgi-src-alloc-2.f90: -------------------------------------------------------------------------------- 1 | !! BAD CLASS(*) ALLOCATION WITH CHARACTER ARRAY SOURCE 2 | !! 3 | !! Fixed in 18.10 4 | !! 5 | !! The following example produces incorrect results with 18.4. 6 | !! The correct results are: 7 | !! 8 | !! ["foo","bar"] 9 | !! 10 | !! But pgfortran gives this: 11 | !! 12 | !! $ pgfortran pgi-src-alloc-2.f90 13 | !! $ ./a.out 14 | !! ["fo",""] 15 | !! 13 16 | 17 | class(*), allocatable :: x(:) 18 | allocate(x, source=['foo','bar']) ! SOMETHING GOES WRONG HERE 19 | select type (x) 20 | type is (character(*)) 21 | print '(''["'',a,''","'',a,''"]'')', x ! expect ["foo","bar"] 22 | if (len(x) /= 3) stop 11 23 | if (size(x) /= 2) stop 12 24 | if (any(x /= ['foo','bar'])) stop 13 ! EXITS HERE 25 | class default 26 | stop 10 27 | end select 28 | end 29 | --------------------------------------------------------------------------------