Bug 11540 - ambiguous using reference is not error
Summary: ambiguous using reference is not error
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P2 minor
Target Milestone: 14.1
Assignee: Sami Wagiaalla
URL:
Keywords:
Depends on: 11832
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-26 07:30 UTC by Jan Kratochvil
Modified: 2023-12-17 13:05 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-04-26 07:30:13 UTC
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'.
Comment 1 Hannes Domani 2023-12-17 13:05:56 UTC
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
```