Skip to content

Clang static analyzer - Past-the-end iterator dereferenced in ranged based for loop #89025

@tgurriet

Description

@tgurriet

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions