Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-81147

Complain about uninitialized members in struct

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Server Programmability

      Recently I had a patch where I converted a std::pair<int, vector> to a struct to improve readability:

      struct MyStruct {
          int errCode;
          std::vector items;
      };
      

      This change introduced the bug that while std::pair initializes the values to defaults (so the int gets initialized to 0), the struct doesn't do this, meaning that there might be a garbage value in the errCode field.

      Can we add a clang-tidy rule to cover this case? Or does Coverity already cover it? See the comments for more info; it seems a memory sanitizer may or may not catch this bug.

            Assignee:
            Unassigned Unassigned
            Reporter:
            vishnu.kaushik@mongodb.com Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: