Menu

False Positive on cppcheck 2.8, uninitvar

2022-11-09
2022-11-09
  • Mark Bourgeault

    Mark Bourgeault - 2022-11-09

    Following code triggers "error: uninitialized variable: s.val2 [uninitvar]"

    struct S {
        int val;
        int val2{123};
    };
    S fn() {
        S s;
        s.val = 0;
        return s;
    }
    

    Note: Initializing val2 via ctor (and not val) is a viable workaround.

     

    Last edit: Mark Bourgeault 2022-11-09
  • CHR

    CHR - 2022-11-09

    This is fixed in head, possibly 2.9 as well.

     

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.