Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-3141

S871, S5303: False positive for explicit constructor calls with a parameter of implicit type

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.21
    • Fix Version/s: 6.26
    • Component/s: Rules
    • Labels:

      Description

      class Test
      {
      public:
        Test() = default;
        explicit Test(const std::vector<int>& dims) : m_dims(dims) {}
        //explicit Test(std::initializer_list<int> dims) : m_dims(dims) {}
      
      private:
        std::vector<int> m_dims;
      };
      
      void gzzz() {
        Test tt;
        tt = Test({ 2, 2 }); // FP
        tt = Test(std::vector<int>{ 2, 2 }); // Correctly ignored
      }
      

        Attachments

          Activity

            People

            Assignee:
            tomasz.kaminski Tomasz Kamiński
            Reporter:
            loic.joly Loïc Joly
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: