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

    <tr>
        <th>Summary</th>
        <td>
            Clang static analyzer - `Past-the-end iterator dereferenced` in ranged based for loop
        </td>
    </tr>

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

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

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

<pre>
    Hello,

I'm using the latest clang-18, and the static-analyzer/clang-tidy through CodeChecker.

I have a little issue with it flagging all my ranged based for loop with `Past-the-end iterator dereferenced`.

For example, in the following function
```
  void log(const log_tags_t & tags, const LogLevel lvl, const std::string & str)
  {
    for (const auto & logger : m_loggers) { logger(tags, lvl, str); }
  }
```

The ` for (const auto & logger : m_loggers)` is being flagged. I can't think of any context in which a range based for loop would do such a thing.

Any idea?

Thanks in advance
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU8tu6zYQ_RpqM7AhUbIeCy0cG0IDZNFF9wEljkg2NGmQIyfu1xeU7QZGs7gXMOih5nHmzPCIGI1yiD3bvbDdMRMLaR96UksIBikbvbz2f6C1nvEDy48s39_OV8abEyzROAWkEawgjASTFU5tipbxAwgnV1ckQWbaCCfs9R8MjA-3KDLyCqSDX5SGg5d40Dh9YNg-4YAWFwQB1hBZBBPjgvBpSIMhmK1QKrUgrIXTFYJwCiWMIqKE2Qew3p9v0azO_xSRNqRxg06CIQyCfACJAWcM6CaUrM6f0AcfAL_E6WwxMTJuJTR7a_1ngp0XN5Hx7p5T5_ffegW4eCPBesV4O3kXKdnvJFR8J2C8hmSmujfnm1dveEEL9mK_v0aSrNyzch8pJMiUFykw3j1QWPPyMGEl_R-cWMivCdYrhQFYuYfT--0SGe9S6t3HePvo5g5_BylfgDXHb6zjj1xv518a05x_r4mUYCKMuA40LRTlFl5hEo7xhoC0cR_gZxDummZC-EVpE5_aTBrEbef_W7lfrATpIS5rUCqinla7d1cwEgUrh2cKwn3EVF_Ii3ATZrIvZVd2IsO-aIqyLHd13WS677CdK875iPU0z13VlEVb7ArezkU71tOYmZ7nvMqrosnrsuLNdhTdWO2aZi7zety1DatyPAljt9ZeTlsfVLa-7r7tcr7LrBjRxlWYnK-KYZwnjYY-xW_GRUVW5dZEit8VyJDF_pDC78KDh_Bg88siSPx_1FK2BNtronNMj5IPjA_KkF7G7eRPjA-pj_vf5hz83zgR48NKKzI-rMz-DQAA__-5_Wf3">