Coverity analysis defect 174833: Use of auto that causes a copy

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • Fully Compatible
    • ALL
    • QE 2025-07-21
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Use of auto that causes a copy

      Unnecessary object copies can affect performance. Using the auto keyword without an & causes a copy.
      /data/mci/22bd5cb6273c9c571686198c9f6023af/bazel_cache/3d8c86e2cd3c28a487a62d019e05fed8/execroot/main/src/mongo/s/write_ops/unified_write_executor/write_op_batcher.cpp:128: AUTO_CAUSES_COPY 174833 Using the "auto" keyword without an "&" causes the copy of an object of type "gnu_cxx::_alloc_traits<std::allocator<mongo::ShardEndpoint>, mongo::ShardEndpoint>::value_type".
      /data/mci/22bd5cb6273c9c571686198c9f6023af/bazel_cache/3d8c86e2cd3c28a487a62d019e05fed8/execroot/_main/src/mongo/s/write_ops/unified_write_executor/write_op_batcher.cpp:128: AUTO_CAUSES_COPY 174833 The variable "shard" has a non-"const" type, however its value is never changed.

            Assignee:
            Niels Lohmann
            Reporter:
            Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: