<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/141119>141119</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Incorrect shape of the result of intrinsic SPREAD
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DanielCChen
      </td>
    </tr>
</table>

<pre>
    Consider the following code:
```
real :: arr
print*, shape(spread(arr, 1, -1))
end
```

Flang produces `-1`. 
However, the standard says: 
```
Case (i): If SOURCE is scalar, the shape of the result is (MAX (NCOPIES, 0)).
```

`NCOPIES` is `-1` in this case, so the shape should be `0`. 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsUsFq3DAQ_ZrxRewijb2OffBB9WZpDm1CQqFXWRqvVRRpkeSE_H2RsyUlLQweLN68eW9mVEr27IkGOHyBw7FSa15CHI7KW3LjuJCvpmDehjH4ZA1Flhdic3AuvFp_ZjoYgloCl9Dya3AZSTlWnmvJVIzA5SVanwEl4MjSoi4E2KVLJGUAuwLBkYny2QnAvgSX5M0nXuDy5JQ_s0sMZtWUGLR8J6DlewZcfg2v9EIbV1GZsvJGRcOSektFyie2USVigJ0t7WrJ7mb2dP_jcbxlNrGklVMfVEUyC_P2EymtLhcQYPdN_izp-3j_cHf7VPD83cD-X-3Q8j-4lm_1V_XMepYXm5hWibYRhb_apiWszrCJCp5vZisz1Kave1XRIG6am77uUfBqGfTMG6xVL1rsOxJza7RR5qYn1U-dIKrsgBwP_IAouoYLvueN0YcW9aQUdhNxaDg9K-v2zr0870M8VzallQbRCCH6yqmJXNquBXEuy4BazjH4XNaFWG4oDqV2N63nBA13NuX0wZZtdtu1vRcfjuzO6xAj6fzfMYeZWZ-j9clq9vTweCuP1RrdsOR8KVsFPAGezjYv67TX4RnwVHpd0-4Swy_SGfC02UiAp6uTlwF_BwAA__8hnOQw">