Can not find what I missed with return value

Discussion in 'C++' started by david, May 5, 2008.

  1. david

    david Guest

    I wrote one function which is used to count comment and code lines and
    it works as it should be, but when compiling I get warning (i686-apple-
    darwin9-g++-4.0.1):

    pirma.cpp: In function ‘int CheckLine(const std::string&, int&)’:
    pirma.cpp:112: warning: control reaches end of non-void function

    So, it looks like somehow it still can get to the end of the function,
    the problem is that I can not figure out that I could have missed.
    This way I added return UNDEFINED at the end of the function, but I
    still would like to get the answer what I could have missed.

    The whole function has only new local variables and if structure:
    int CheckLine(const string &line, int &status) {
    string::size_type startPos;
    bool emptyStatus = true;

    if (status == CODE || status == EMPTY) {
    ...........
    } else {
    .........
    }
    //return UNDEFINED;
    }

    if there is something I could have missed, it would be in the else
    statement, but it looks perfect for me. Any ideas?
     
    david, May 5, 2008
    #1
    1. Advertising

  2. david

    Krice Guest

    david kirjoitti:
    > //return UNDEFINED;
    > }
    > if there is something I could have missed


    You forgot to uncomment that return.
     
    Krice, May 5, 2008
    #2
    1. Advertising

  3. david

    david Guest

    I am not that silly, I commented it that I could check/change code to
    locate. But it looks that I found what I was looking after making
    large scale tests.
     
    david, May 5, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ABC
    Replies:
    0
    Views:
    350
  2. ABC
    Replies:
    0
    Views:
    484
  3. Joe
    Replies:
    25
    Views:
    2,141
    Neredbojias
    Apr 21, 2006
  4. Replies:
    0
    Views:
    458
  5. Greenhorn
    Replies:
    15
    Views:
    832
    Keith Thompson
    Mar 6, 2005
Loading...

Share This Page