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

    <tr>
        <th>Summary</th>
        <td>
            clang(++) unhelpful `frame-larger-than` warning, very small stack exceeding very large limit
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Both clang and clang++ output an unhelpful warning for the following code:
```cpp
void a() { char b[4294967281] = {0}; }
```
The warning:
```
unhelpful-warning.c:1:6: warning: stack frame size (8) exceeds limit (4294967295) in 'a' [-Wframe-larger-than]
void a() { char b[4294967281] = {0}; }
     ^
```
The warning reads to me as if 8 is the stack frame size of the function and 4294967295 is the upper limit on the stack size. With 8 however being significantly smaller than the limit and also not matching the size of the array in the function body, this seems rather odd.

The warning above was generated by clang `15.0.0-++20220824072824+4e4252f9b649-1~exp1~20220824072835.36`.
clang 14.0.6 also shows this warning, but not just for a zero initialized array, but also for an unitialized one:
```cpp
void a() { char b[4294967273]; }
```

For clang 15 (run inside a podman container with the latest ubuntu image from Docker hub) the smallest array size to trigger the warning seems to be `4294967281`. Whereas with clang 14.0.6 it's slightly smaller at `4294967273`. Which both are still below the stack size limit. The warning also occurs for larger sizes.
For reference, the ubuntu container has glibc version `2.35-0ubuntu3.1` and my regular linux has version `2.36-3` from the Arch repos, in case that makes a difference for the stack layout.

I stumbled upon this issue while messing around with the code from #57317.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVctu4zgQ_Br50rCgt-yDDvFmAux9gZwpqiVxQokCH0k8X79N0o7tDTB72DVkyyKbzaruKqpXw7k7KTsDl2ydgK1D_JcUJ7pAObs5S8Pg1hnlNjoJH0yvgmJHpcHOSHcp1Ycf4WrApHxKsucke0qaLF582-LIuxIDsKQ4JMURkvYEfGYa-qQ-Vc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