Issue 74274
Summary [Flang] Incorrect execution result when F edit descriptor with decimal places set to 0
Labels flang:frontend
Assignees
Reporter ohno-fj
    ```
Version of flang-new : 18.0.0(770dc47659d41a5ca7b7daf5b3134c900ca8c33d)
```

The result of setting the number of decimal places to zero in `F edit descriptor` is different when the variable is initialized to `real literal constant` with `_kind` than when it is initialized to `real literal constant` without `_kind`.


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


d12_34.f95:
```fortran
program main
 real(kind=8),parameter::a1=1.618033988749895_8
 real(kind=8),parameter::b1=-0.618033988749895_8
 real(kind=8),parameter::c1=2.23606797749978969641_8
 real(kind=8),parameter::a2=1.618033988749895
 real(kind=8),parameter::b2=-0.618033988749895
 real(kind=8),parameter::c2=2.23606797749978969641
  integer::N=2
 write(6,*) "(a1**N-b1**N)/c1 = ", (a1**N-b1**N)/c1
 write(*,"(f20.0)") (a1**N-b1**N)/c1
  write(*,"(f20.1)") (a1**N-b1**N)/c1

  write(6,*) "(a2**N-b2**N)/c2 = ", (a2**N-b2**N)/c2
  write(*,"(f20.0)") (a2**N-b2**N)/c2
 write(*,"(f20.1)") (a2**N-b2**N)/c2
end program main
```

```
$ flang-new d12_34.f90; ./a.out
 (a1**N-b1**N)/c1 =  .9999999999999998
                  0.
 1.0
 (a2**N-b2**N)/c2 =  1.
                  1.
 1.0
$
```

```
$ gfortran d12_34.f90; ./a.out
 (a1**N-b1**N)/c1 =   0.99999999999999978
                  1.
 1.0
 (a2**N-b2**N)/c2 =    1.0000000000000000
 1.
                 1.0
$
```

```
$ ifort d12_34.f90; ./a.out
 (a1**N-b1**N)/c1 =    1.00000000000000
 1.
                 1.0
 (a2**N-b2**N)/c2 =    1.00000000000000
 1.
                 1.0
$
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to