Menu

uninitvar FP?

jacob s
2021-12-23
2021-12-25
  • jacob s

    jacob s - 2021-12-23

    cppcheck d36aa590cdd499d2f41e42c79dec607a91c0edf5

    given:

    static int func() {
        int rc;
    
        while (true) {
            rc = func();
            break;
        }
    
        return rc;
    }
    

    yields:

    x.c:9:12: error: Uninitialized variable: rc [uninitvar]
        return rc;
               ^
    x.c:4:12: note: Assuming condition is false
        while (true) {
               ^
    x.c:9:12: note: Uninitialized variable: rc
        return rc;
    
     
  • Daniel Marjamäki

    true does not mean anything in C so you need to define it.

     

    Last edit: Daniel Marjamäki 2021-12-25

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.