A function like this one won't return two values, right?

Just wondering if the language will know that I intend to return ONLY ONE VALUE. Here is my function (I have a sentry variable, but was trying to avoid adding algorithmic complexity):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
bool assemblytoopcode::checkduplicates()
{
    for (int j = 0; j < (int)labels.size(); j++)
    {
        for (int k = j; k < (int)labels.size(); k++)
        {
            if (k = j)
            {
                //Do nothing; the compiler won't let me define k > j...
            }   //end if
            else if ((labels[j] == labels[k]) && (k > j))   //If the label is already in the vector...
            {
                cout << "ERROR: Label "<<labels[j]<<" on line "<<j<<" already exists."<<endl;   //Report that incident to the user!!
                goto returnerror;      //Get me out of here!!
            }   //end else if
        }   //end inner for
    }   //end outer for
    return false;
    returnerror: return true;
}   //end checkduplicates 
goto is generally frowned upon. You could simply replace that line with return true; and it should function the same unless I am mistaken?
return immediately exits the function, so the compiler does not have to know anything. It'll do the right thing.
What's the goto supposed to accomplish? Replace it by return true; directly.

This is an assignment, by the way: if (k = j)
And you can negate a condition, no need for strange else constructs:
1
2
3
4
if (!(labels[j] == labels[k] && k > j))   //If the label is already in the vector...
{
  [...]
}

or
if (labels[j] != labels[k] || k <= j) //If the label is already in the vector...
Holy crap, I overcomplicated this! Thanks, guys!!
Topic archived. No new replies allowed.