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

    <tr>
        <th>Summary</th>
        <td>
            Clang latest segfaults on relatively few member factory expressions (works with gcc)
        </td>
    </tr>

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

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

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

<pre>
    Example: [https://godbolt.org/z/99GPhrf5j](https://godbolt.org/z/99GPhrf5j)

The following code
```
struct member_factory {
    member_factory() {}

    auto w() {
        return *this;
    }
};

auto p = member_factory()
.w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w()
.w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w().w()
...
```
causes a segmentation fault after relatively few calls ~1600 to w(). This issue manifested when binding a couple thousand macros from a C library to make them accessible from a scripting language and this limit seemed a bit small to me so I thought to report it here.

It looks like Clang is running out of some resource after a couple thousand rounds of this recursive loop.
```
  #2 0x000056468e0412a6 SignalHandler(int) Signals.cpp:0:0
  #3 0x00007fbad1a51f50 (/usr/lib/libc.so.6+0x38f50)
 #4 0x0000564690c027bb clang::Stmt::getBeginLoc() const (llvm/clang-17+0x45c97bb)
  #5 0x0000564690a770f5 clang::CallExpr::getBeginLoc() const (llvm/clang-17+0x443e0f5)
  #6 0x0000564690c02892 clang::Stmt::getBeginLoc() const (llvm/clang-17+0x45c9892)
  #7 0x0000564690a77993 clang::MemberExpr::getBeginLoc() const (llvm/clang-17+0x443e993)
  #8 0x0000564690c027c0 clang::Stmt::getBeginLoc() const (llvm/clang-17+0x45c97c0)
  #9 0x0000564690a770f5 clang::CallExpr::getBeginLoc() const (llvm/clang-17+0x443e0f5)
 #10 0x0000564690c02892 clang::Stmt::getBeginLoc() const (lvm/clang-17+0x45c9892)
 #11 0x0000564690a77993 clang::MemberExpr::getBeginLoc() const (llvm/clang-17+0x443e993)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUls1u2zgQx5-GvgwqUKT1ddDBievdArvAAu19QVEjiQ1FCvyIkz3ssy8oO4nj5lBsgwI1bNnSjP6_Gc54ROG9Gg1iS4obUuw3IobJutYa1HFWZtPZ_rH9-CDmRSPhOyDFzRTC4gnfEXYg7DDavrM6ZNaNhB3-IezQNL_9Nbmh-EqKPWH197uzhtA9obvT8cuEMFit7VGZEaTt8Wwt6fm9nvrgogww49yh-3sQMlj3CKS6OZkB4MpGWE1Ys3pU-0tgchUxWDheuDxb0sthiM4AYbswKU_4hflFq9o_G07HVXMBwvdvRnJyys7QX-X7l446y95sJSmiRw8CPI4zmiCCsgYGEXUAMQR04FCLoO5RP8KAR5BCaw__5iWl8NI3GXyZlAflfUSYhVED-oA9HCc00CnTp34WIG1cNEKYbPTC9DAL6ayHwdkZBNyCVp0T7jEJz-IuOeIMQkr0XnUanxy9dGoJSVILM0YxIiS11KCg1awCeMQZexDQpZNZaL1qIngLn1b-OIV0yeFiXQAVYEKH2WUPfwqgrb1LkncItwkFyoOLxiS0jQHsAN7OCA69jU7iecm-TdTZaHqf_NcgHcrovLrHRFjergwAYZwBfaCU0qLcljXSbc5ECZ_VaIT-XZheoyOsViakv-7pss_kshC-o-vnRYmflaqhE30uinwoKKzFO0TvCDto1Z2OMvM2Kwm7oQ-8Hgr63ENJZnsRUEMlZVXXgUxrk8Yd330Oczj9GjHc4KjMH1aeZ4u0xofE1Pp-Juyw3vYhr1bUtpBN1XUvsEQrXtFEVdGhuKTdCq0_Pizu_xG3HOlQvCaW1_nVDXu3_OqGvaZV1_k1Db-k_bnOzh_KsGn4a2b9TQUlfb8KSvqa1vzUChLGc_ouFfyOAiZY_nML-DwiNn3L-4Y3YoNtXtZbXrKqbjZTKxirSimboUIsWI-C94MoqrromeyGCjeqZZRxWuQVY5zTJstrwYuCdX237RtWItlSnIXSWQoo7Vk261RvE6HeaNGh9k87J9cmpw9dHD3ZUq188C-3BRU0tqe5qUVAn8byuD5aPFhz_WA57RPgaTeDD4tLY98an1bnaN2dh6MKE4xSEtZsotPt1T5LhSl2mbRpHc_Luca3OPsVZSDssKbiCTus2fwXAAD__zXi3Y4">