Issue 134565
Summary [Flang] Quadruple precision COMPLEX used in TYPE IS statement in SELECT TYPE construct is not executed correctly
Labels flang
Assignees
Reporter ohno-fj
    ```
Version of flang : 21.0.0(06cb7b1e14a117e8fe19b72689c8616c772c0807)/AArch64
```
As in the attached program, `Quadruple precision COMPLEX` used in `TYPE IS statement` in `SELECT TYPE construct` is not executed correctly.  
The above program is `sngg956k_42.f90`.

Since a simple program that outputs a variable of `Quadruple Precision COMPLEX` can be executed, there should be no problem to use `Quadruple Precision COMPLEX`.

When the program is modified as follows, it executes correctly.
- Change `Quadruple precision COMPLEX` to `Double precision COMPLEX`, or  
  The above program is `sngg956k_43.f90`.
- Change `Quadruple precision COMPLEX` to `Quadruple precision REAL`  
  The above program is `sngg956k_44.f90`.


The following are the test program, Flang, Gfortran and ifx compilation/execution result.

sngg956k_42.f90:
```fortran
program main
  class(*),allocatable :: obj
  allocate(complex(16)::obj)
  k=0
  select type(p=>obj)
  type is(complex(16))
     p=(2,3)
     k=1
     write(6,*) "in select type construct"
  end select
  write(6,*) "k = ", k
end program main
```

```
$ flang sngg956k_42.f90; ./a.out
 k =  0
$
```

```
$ gfortran sngg956k_42.f90; ./a.out
 in select type construct
 k = 1
$
```

```
$ ifx sngg956k_42.f90; ./a.out
 in select type construct
 k =            1
$
```

sngg956k_43.f90:
```fortran
program main
 class(*),allocatable :: obj
  allocate(complex(8)::obj)
  k=0
  select type(p=>obj)
  type is(complex(8))
     p=(2,3)
     k=1
     write(6,*) "in select type construct"
  end select
  write(6,*) "k = ", k
end program main
```

```
$ flang sngg956k_43.f90; ./a.out
 in select type construct
 k =  1
$
```

sngg956k_44.f90:
```fortran
program main
 class(*),allocatable :: obj
  allocate(real(16)::obj)
  k=0
  select type(p=>obj)
  type is(real(16))
     p=(2,3)
     k=1
     write(6,*) "in select type construct"
  end select
  write(6,*) "k = ", k
end program main
```

```
$ flang sngg956k_44.f90; ./a.out
 in select type construct
 k =  1
$
```

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

Reply via email to