| Issue |
178426
|
| Summary |
[flang] SIZE incorrectly accepts non-constant TRANSFER argument in constant _expression_ context
|
| Labels |
flang
|
| Assignees |
Ritanya-B-Bharadwaj
|
| Reporter |
Ritanya-B-Bharadwaj
|
Flang incorrectly accepts SIZE(TRANSFER(variable, mold)) in constant _expression_ contexts where the TRANSFER argument is a non-constant variable. For inquiry functions like SIZE/SHAPE applied to a non-variable argument (such as a function call result), the argument must itself be a constant _expression_ for the result to be a constant _expression_.
Reproducer:
```
implicit none
type t
integer :: n
end type t
type(t) :: s
integer :: k = size (transfer (s,[1]))
integer, parameter :: m = size (transfer (s,[1]))
end
```
Expected behavior:
Both declarations should produce an error because s is a variable, not a constant, so TRANSFER(s, [1]) is not a constant _expression_, and therefore SIZE(TRANSFER(s, [1])) cannot be a constant _expression_.
gfortran produces:
```
test.f90:32:44:
32 | integer :: k = size (transfer (s,[1])) ! No ICE
| 1
Error: Parameter 's' at (1) has not been declared or is a variable, which does not reduce to a constant _expression_
bug_847265.f90:33:44:
33 | integer, parameter :: m = size (transfer (s,[1])) ! ICE
| 1
Error: Parameter 's' at (1) has not been declared or is a variable, which does not reduce to a constant _expression_
```
Actual behavior:
Flang compiles without error.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs