Complain about uninitialized members in struct

XMLWordPrintableJSON

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

      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
              Reporter:
              Vishnu Kaushik
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated: