This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16463] Global variable/class method name collision


https://sourceware.org/bugzilla/show_bug.cgi?id=16463

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |palves at redhat dot com

--- Comment #1 from Pedro Alves <palves at redhat dot com> ---
I don't see this as "collision", but a consequence of the fact that expression
printing follows the language's scoping rules.  Code inside the "global"
function wouldn't be able to refer to the "global" global without scoping
either, with:

  int global (void) const { return ::global; }

We may want a way to broaden the scope, but this wouldn't be C++-specific. 
E.g., the OP example seems no different to me from, say:

file1.cc:
 static int foo (void) { return 1; }
 int main (void) { return foo (); }

file2.cc:
 int foo = 1;

and then when stopped at main, trying to print foo.  It'll print the function.

Or, trying to print 'bar' from any scope, when you have:

file3.cc:
 static int bar;

file4.cc:
 static int bar;

(which to print?)

(The workaround in these cases is p 'file.cc'::foo)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]