Menu

bug:cppcheck can not repoprt missingReturn error ,when func has loop

zhudongmei
2024-03-20
2024-03-20
  • zhudongmei

    zhudongmei - 2024-03-20

    description: func should return value,but cppchek not report error,find func have a loop
    version: cppcheck 2.13.0

    # /usr/bin/Cppcheck/cppcheck --debug --enable=warning,performance,portability test.c
    Checking test.c ...
    
    
    ##file test.c
    1: int f1 ( )
    2: {
    3: int i@var1 ; i@var1 = 0 ;
    4: for ( i@var1 = 0 ; i@var1 ++@exprUNIQUE ;@exprUNIQUE i@var1 <@exprUNIQUE 10 )
    5: {
    6: i@var1 ++@exprUNIQUE ;
    7: }
    8: }
    9:
    10: int f2 ( )
    11: {
    12: }
    
    
    
    ##Value flow
    File test.c
    Line 3
      = always 0
      0 always 0
    Line 4
      = always 0
      0 always 0
      i possible {0,2}
      ++ possible {0,2}
      i possible 2
      < {!<=-1,!>=2,1}
      10 always 10
    Line 6
      i possible 1
      ++ possible 1
    test.c:12:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
    }
    
     
  • CHR

    CHR - 2024-03-20

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11722

     

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.