Menu

False positive constVariable

2022-01-17
2022-01-17
  • Anton Davidenko

    Anton Davidenko - 2022-01-17

    example:

    struct S
    {
        int i;
    };
    
    void foo(const S &s)
    {
        auto& x = s.i;
    }
    
     
  • CHR

    CHR - 2022-01-17

    Isn't this a true positive? An unread variable can technically be const.

     
  • Anton Davidenko

    Anton Davidenko - 2022-01-17

    It's already const because 's' is const

     
  • CHR

    CHR - 2022-01-17

    constmight still improve readability though.

     

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.