Skip to content

Commit 450dc5c

Browse files
committed
Add new NAG 6.2 bug test case
1 parent 2cb5317 commit 450dc5c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

nag-bugs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include(testing)
55

66
project(nag-bug Fortran)
77

8+
add_compiler_test(SOURCES nag-20200110.f90 RUN_ONLY COMPILE_FLAGS "-O")
89
add_compiler_test(SOURCES nag-20190906.f90 RUN_ONLY LABELS SR104066)
910
add_compiler_test(SOURCES nag-20190831.f90 RUN_ONLY LABELS SR104066)
1011
add_compiler_test(SOURCES nag-20190826a.f90 COMPILE_ONLY LABELS SR104042)

nag-bugs/nag-20200110.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
!! WRONG CODE UNDER OPTIMIZATION
2+
!!
3+
!! The 6.2 compiler generates wrong code for the following example
4+
!! when compiled with -O. The array ARR2 should ultimately have the
5+
!! same size as ARR1, but instead has size 0.
6+
!!
7+
!! Credit to David Neill-Asanza (dhna@lanl.gov) for this reproducer.
8+
!!
9+
!! $ nagfor -O nag-20200110.f90
10+
!! NAG Fortran Compiler Release 6.2(Chiyoda) Build 6243
11+
!!
12+
!! $ ./a.out
13+
!! STOP: 1
14+
15+
integer :: i, arr1(32)
16+
integer, allocatable :: arr2(:)
17+
arr1 = [(i, i=1,size(arr1))]
18+
arr2 = arr1
19+
arr2 = arr2 * 2
20+
if (size(arr2) /= size(arr1)) stop 1
21+
if (any(arr2 /= 2*arr1)) stop 2
22+
end
23+

0 commit comments

Comments
 (0)