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

    <tr>
        <th>Summary</th>
        <td>
            C++ compile error. - Non-const lvalue reference to type 'int[y - 2]'
        </td>
    </tr>

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

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

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

<pre>
    For the following code snippet, gcc is able to compile without any warnings and errors, however, clang emits compile error code “lvalue_reference_bind_to_unrelated”.

gcc: https://godbolt.org/z/q3fEqKGb6
clang: https://godbolt.org/z/f51Ehd6s1 
Code snippet:
```
void
foo (int &x, int &y)
{
  int err = 0, i;
  int a[y - 2], b[y - 2];
  int (&c)[y - 2] = a, (&d)[y - 2] = b;
}
```

Error message from clang:
```
<source>:6:9: error: non-const lvalue reference to type 'int[y - 2]' cannot bind to a value of unrelated type 'int[y - 2]'
  int (&c)[y - 2] = a, (&d)[y - 2] = b;
        ^           ~
<source>:6:26: error: non-const lvalue reference to type 'int[y - 2]' cannot bind to a value of unrelated type 'int[y - 2]'
  int (&c)[y - 2] = a, (&d)[y - 2] = b;
                         ^           ~
2 errors generated.
```

The error message seems weird to me since the type it wants to bind is the same type.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVE2P4zYM_TX0hUjgULHjHHzIZw8Feup9IMu0rUKWspI8aXroby9kZ2Z32tmiKHqqEDg0-B4lPj1ThqB7y1xDcYTinMkpDs7XatBqmKwa2GaNax_11XmMA2PnjHF3bXtUrmUMVt9uHIFO2CuFOqBsDGN0qNx404bxruPgpojSPvAuvdW2Dyhti-y98yExB3fnV_YpVEbaHnnUMbxXmIHLdnAhqHLYn8yrNBO_eO7Ys1X80mjbvkT3MlnPRkZu36DnNeRnyA_Ls1cKxAGHGG8BxAHoCnTtXds4E9fO90DX34CuX0R3-fLjD025sOZT_RNeV2wuQ1uGDS7E07caiecZoMyfv_n11el2iTrnEKjSNiJQ-WvS4xk_gPZP8u64BDjn2HsEccZ8BoP4kJRQHB-4QoLinPLNt-8foUAVUKnSNl8xc2WZmEu6_STdvBeC3fnT_pbnZb7EkUOQPWPn3Yhvqn7OEqfgJq8YxAXEoQRx2KcbmM2QAuvsSjkbIi5ewHcvJPfFx40RaKdt_CDCDpW01kVMfklAiQvbdfhune-z_2PJ8LmguODX9ft3FaDyfyvBX9anmtBzamDPln066PpvPPfz8DY83nwXmMeAd9Z-7nxkDHqWa-ClYx3xLm0MKTvro8OcDHJcEOusrUW7F3uZcb0pqz3tcpGLbKjzKpfbLTVCSa5oS50o9wXlou2qDYtNk-machL5biM2u22Ri3WlCtpt1J62jeyKqoRtzqPUZm3M65imSqZDmLguRVVQZmTDJsxzmmj5digJmvk64VfN1AfY5kaHGL5WiDoark9AR6Djx5G6xhX-9O8slE3e1H8ahjoOU7NWbgS6pu2ff6ubd7-wikDXuZsAdJ0b-iMAAP__lsDfEA">