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

    <tr>
        <th>Summary</th>
        <td>
            New dialect flag: -farray-parameters-are-arrays
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          alejandro-colomar
      </td>
    </tr>
</table>

<pre>
    GCC ticket: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121331>

Cc: @AaronBallman 

This is a stronger version of -farray-parameters-are-const, proposed in
<https://github.com/llvm/llvm-project/issues/151526>.

It would make array parameters work as real arrays in every way: sizeof(), typeof(), _Generic(), ...

This would affect the function scope, but not it's callers.

Let's write some examples, to make it clear:

```c
        void
        f(int size, char buf[size], pid_t pid)
        {
                if (stprintf(buf, _Countof(buf), "/proc/%d/", pid) == -1)
                        return;
                ...
                return;
        }

        char *a = malloc(100);
        f(100, a, 0);  // Ok; at call site pointers are valid.

        void
        g(int size, char buf[size], pid_t pid)
        {
                buf = NULL;  // error: assignment to expression with array type
        }

        void
        h(char *buf;
          int size, char buf[size], pid_t pid);  // error: redeclaration with different type

        void
        i(char buf[];
          int size, char buf[size], pid_t pid);  // okay

        void
        i(char buf[size];
          int size, char buf[size], pid_t pid);  // okay
```

This is a breaking change, so it must be opt-in.

However, there shouldn't be much code that is relying on the old behavior, as most of it is already diagnosed by default.

---

With this flag enabled, the only difference with real arrays would be that these could be null.  Other than that, they'd be real arrays.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU2P2zYQ_TX0ZWBBoix_HHTw2nFaYJFcWvS4GFEjiTFFCiRlx_n1BSlrvWlSFEUWMCyJH--9eUPOoHOy1UQlK55YcVzg6DtjS1T0BXVtzVIYZXq0i8rUt_Lj4QBeijN5lu-B5YfO-8GxfM_4ifFTK0TS6jExtmX8VI3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