Q:

GCC generated crazy program

Look this piece of code:
vector<Command*> list;
int cur = -1;

if( cur < (list.size()-1) )
{   
    cout<<"redo"<<endl;
    ++cur;
    list[cur]->execute(text);
    cout<<"pos: "<<cur<<" size: "<<list.size()<<endl;
}   
else
{   
    cout<<cur<<" "<<(list.size()-1)<<" "<<( cur > (list.size()-1) )<<endl;
}   
if(-1>2)
    cout<<"true"<<endl;
else
    cout<<"false"<<endl;

It's printing: 
-1 2 1 

false

which means:

cur = -1
list.size()-1 = 2
cur > list.size()-1  == true, i.e. -1 > 2

but the other if says it's false and math say the same.
My GCC version is: gcc version 4.8.0 (rev2, Built by MinGW-builds project)
am I the problem or GCC?

A:

Perhaps cur is signed and list.size is unsigned. 
Then in this expression:
cur > (list.size()-1)

cur gets converted to unsigned, so the value is true.

You may try this simple sample, c gets value false.
int a = -1;
unsigned int b = 1;
bool c = a < b;

