namespace A { int x = 1; } namespace B { int x = 2; } int main (void) { using namespace A; using namespace B; return 0; } ------------------------------------------------------------------------------ If I would use `return x;' the compiler would complain: 1.C:7: error: reference to ‘x’ is ambiguous 1.C:2: error: candidates are: int B::x 1.C:1: error: int A::x ------------------------------------------------------------------------------ But in GDB I get: 7 return 0; (gdb) p x $1 = 1 and after I switch using namespace B; using namespace A; I get: (gdb) p x $1 = 2 ------------------------------------------------------------------------------ GDB thus does not have the behavior of compiler. Expecting something like: (gdb) p x Reference to ‘x’ is ambiguous, candidates are `int B::x', `int A::x'.
This is working since gdb-14.1, was fixed by this commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=bb391cb24d8f92ecad10bb6a60abdf0b880de0dd Now you get: ``` (gdb) p x Reference to "x" is ambiguous, possibilities are: A::x and B::x ```