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

    <tr>
        <th>Summary</th>
        <td>
            Clang: Crash on capturing invalid structured binding declaration in lambda expression
        </td>
    </tr>

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

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

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

<pre>
    The following code ICE's (crash on invalid) on trunk, and going back to at least clang 16.0.6

```c++
struct Point {
   int x;
   int y;
};

Point get_point() { return { 1, 2 }; }

int main() {
    auto& [x, y] = get_point();

    bool b = [x, y] {
 return true;
    }();

    return b;
}
```

Godbolt link: https://godbolt.org/z/bvEbbc6hj

The compiler correctly diagnoses that we need to use `auto&&` for these variables if we want to use them in a structured binding declaration of an rvalue.... and then crashes.

 I ran into this refactoring some code that manually extracted these members (that were already captured in a lambda expression) to use a structured binding. This made clangd crash outright instead of letting me know that I had an error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVMFu4zYQ_Rr6MlhBoizZPuiQxOsi6KWHvRdDcixxQ5EGOXLifn1BSZvEaYsChERRfI_vDR4HU7K9J-pE8yia4wYnHkLsHo6_Y2KKGxXMrfsxEJyDc-HV-h50MATPT9-F3CUQcq8jpgGCB-uv6KwR8pC_OE7-RcgnQG-gDxmpUL8AB0AGR5gYtEPfQ9UWZdGK8ijKh_XZlsvQQj7mMa8mjpNm-CNYzyB26yoA5O83Ud8v3N4XxO74MZ-fC0VP_Oclz4TcZ9Fi9wiReIp-nlZZvIQFPb8-MWT8iNZ_QN8PB5w4CNmCaB7fMsdNNEcQ9fHrgV9EZagKwYGaN9-j3_lXgRwn-ux41vdfrCtG3VXkvtCfIb8Fo4JjcNa_iPoBBuZLEvWDkCchT_3ytwixF_L0l5Andf2ulG6Hn59JcmZ0GC_WUQQdYiTN7gbGYu9DogQ8IMMrgScyORRTIhBtuRYvj7aEc4jAAyWCK0aLylECe86wV_T8C8YDjWA9ICwRmSIZUNabHDpD2mFEtsFDOAN6iFd0ExVFUczZ5IE8zCGmVNyV7hki5lhzAB5sgkhn1Bxipk1hpOUqzEZG9BM6dwN644iayay6RxoVxfmirI4jAbpIaG6g8bKIncU7HJVBoLdLpJRs8DlZq8V_s1bAj6xqREPLTTKw3sWJo-0HBusTE5rs2xFz1j0SvPjwuqh-hgFNLgnFGGKxMV1tDvUBN9RV7aHZtU1V7zdDV-5xrw1VdV3Wpm0rsz3Ukva1VLKSZrvb2E6Wsi4PspVVI6t9UZZlo9Wh2m735935XIptSSNaVzh3HXN2Njalibp2tz00G4eKXJp7kJSzFSFlbkexy_u_qalPYls6mzh9MLBlR93TvL1-gKdffWipaja7dqT_i4X1_6z9Zoqu-5J8y8OkCh1GIU9Zxfr6donhJ2kW8jSbSkKeZl9_BwAA___haKs_">