Why gdb "set" command doesn't recognize global variable, must add "::" or "variable"?
<p>I was trying to set value in gdb, I have:</p>

<pre><code>int i=0;
int main(){
  ++i;
  int j=i+2;
  return 0;
}
</code></pre>

<p>break at "return", and "r"</p>

<pre><code>(gdb) set j=4
(gdb) set i=5
Ambiguous set command "i=5": .
(gdb) set ::i=6
(gdb) set variable i=6
</code></pre>

<p>It's weird, "j" is local variable in main, so "set" with no problem.
While "i" is a global one, seems I should add either "::" or "variable" to make it set.</p>

<p>I searched internet, and it says "variable" is used to set gdb/reg variables used inside debugging sesssion.</p>

<p>Why "i" still requires "variable"?</p>