Menu

variable not initialized

michele
2015-11-13
2015-11-18
  • michele

    michele - 2015-11-13

    I did this simple test

    static BOOL Test(U16 zCase)
    {
    BOOL zResult;

    switch ( zCase )
    {
    case 1:
    zResult = TRUE;
    break;

      case 2:
         zResult = FALSE;
      break;
    
      default:
      break;
    

    }

    return zResult;
    }

    I would expect a cppchcek warning because zResult can have an unknown value .. isn't it?
    Thanks
    Michele

     
  • Daniel Marjamäki

    Yes we should write an error for that.

    There is a ticket:

    http://trac.cppcheck.net/ticket/4784

     
  • Daniel Marjamäki

    Btw.. it is interesting if you can find some more simple cases. I doubt that we have thought about all possible cases. Thanks!

     
  • michele

    michele - 2015-11-18

    Yes, for sure.
    Michele

     

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.