Issue 98981
Summary [Flang] No error checking when array intrinsic assignment uses an array of derived type with a different shape
Labels flang:runtime
Assignees
Reporter ohno-fj
    ```
Version of flang-new : 19.0.0(73447a3302541c343525570222b318e7f94f9402)/AArch64
```

When `array intrinsic assignment` uses an array of `derived type` with a different shape, no compilation-time error message is outputted. (vcommta_22.f90) 
When `derived type` is changed to `integer type`, an error is detected and a compilation-time error message is outputted. (vcommta_42.f90)


The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

vcommta_22.f90:
```fortran
program main
  type t
 integer i1
  end type t
  type(t),allocatable::b(:)
 allocate(b(10))
  b%i1=1
  b(1:10)=b(10:1)
  print*,b(1)%i1
 deallocate(b)
end program main
```

```
$ flang-new vcommta_22.f90; ./a.out

fatal Fortran runtime error(/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/CHMK23/vcommta_22.f90:8): Assign: mismatching element counts in array assignment (to 10, from 0)
Aborted (core dumped)
$
```

```
$ gfortran vcommta_22.f90; ./a.out
vcommta_22.f90:8:2:

    8 | b(1:10)=b(10:1)
      |  1
Error: Different shape for array assignment at (1) on dimension 1 (10 and 0)
$
```

```
$ ifort -diag-disable=10448 vcommta_22.f90; ./a.out
vcommta_22.f90(8): error #6366: The shapes of the array expressions do not conform.   [B]
 b(1:10)=b(10:1)
--^
compilation aborted for vcommta_22.f90 (code 1)
$
```

vcommta_42.f90:
```fortran
program main
 integer,allocatable::b(:)
  allocate(b(10))
  b=1
 b(1:10)=b(10:1)
  print*,b(1)
  deallocate(b)
end program main
```

```
$ flang-new vcommta_42.f90
error: Semantic errors in vcommta_42.f90
./vcommta_42.f90:5:3: error: Dimension 1 of left-hand side has extent 10, but right-hand side has extent 0
 b(1:10)=b(10:1)
    ^^^^^^^
$
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to