Menu

Member variable "" is not initialized in the constructor.

DarrenSong
2022-07-01
2022-07-06
  • DarrenSong

    DarrenSong - 2022-07-01

    the member variable is initialized in the constructor, but it still report this error .pls see the detail as below.
    DunleeCT8000StateContext::DunleeCT8000StateContext()//:mDuleeXsegmentDev(NULL)<--- Member variable 'DunleeCT8000StateContext::mDuleeXsegmentDev' is not initialized in the constructor.
    {
    m_DuleeXsegmentDev = NULL;
    m_StopShotCallBack=boost::function<void ()="">();
    m_dfu_comm_send_suc=false;
    m_fila_comm_send_suc=false;
    }
    i want to know how to fix it or if it is a bug?. cppcheck version is v2.8</void>

     
  • CHR

    CHR - 2022-07-01

    I can't reproduce the issue for

    DunleeCT8000StateContext::DunleeCT8000StateContext() {
        m_DuleeXsegmentDev = NULL;
        m_StopShotCallBack=boost::function<void()>();
        m_dfu_comm_send_suc=false;
        m_fila_comm_send_suc=false;
    }
    
     
  • Daniel Marjamäki

    please show the declaration for m_DuleeXsegmentDev

     
    • DarrenSong

      DarrenSong - 2022-07-06

      the class definition is below
      class DunleeCT8000StateContext {
      public:
      funtion1();
      funtion2();
      ...
      funtionn();
      private:
      IDunleeXrayDevice* m_DuleeXsegmentDev

      };

       
  • Daniel Marjamäki

    I think a small code example would be good so we can reproduce. I assume 7-8 lines of code is enough. Can you reproduce with:

    class DunleeCT8000StateContext {
    private:
        // Declaration for m_DuleeXsegmentDev here
    public:
        DunleeCT8000StateContext() {
            m_DuleeXsegmentDev = NULL;
        }
    };
    
     

    Last edit: Daniel Marjamäki 2022-07-05
    • DarrenSong

      DarrenSong - 2022-07-06

      i reproduce with your code,it does not report this error, thanks a lot.
      but i wander why cause this cause?

       
      • Daniel Marjamäki

        I assume there is a detail in your code that confuses Cppcheck. I would suggest that you reduce your code to find out why Cppcheck writes a false positive.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.