This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
gdb/828: GDB doesn't know about anonymous namespaces
- From: carlton at math dot stanford dot edu
- To: gdb-gnats at sources dot redhat dot com
- Date: 15 Nov 2002 21:37:18 -0000
- Subject: gdb/828: GDB doesn't know about anonymous namespaces
- Reply-to: carlton at math dot stanford dot edu
>Number: 828
>Category: gdb
>Synopsis: GDB doesn't know about anonymous namespaces
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Nov 15 13:38:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: carlton@math.stanford.edu
>Release: GNU gdb 2002-11-15-cvs
>Organization:
>Environment:
any
>Description:
GDB doesn't know about anonymous namespaces in C++. This
is particularly unfortunate since the use of 'static' to
mean file-local is deprecated in C++, with anonymous
namespaces as the suggested replacement.
>How-To-Repeat:
Compile this file:
// Example of an anonymous namespace.
namespace {
int x = 1;
}
int main()
{
x;
return 0;
}
Then run GDB on it and try to print out 'x':
(gdb) b main
Breakpoint 1 at 0x80484a0: file anonymous.cc, line 11.
(gdb) r
Starting program: /cartan/carlton/sync/gdb-backup/namespace/prs/anonymous
Breakpoint 1, main () at anonymous.cc:11
11 return 0;
(gdb) p x
No symbol "x" in current context.
(gdb) p '(anonymous namespace)::x'
$1 = 1
>Fix:
For now, a workaround is to refer to symbols in anonymous
namespaces explicitly by prefixing them with '(anonymous
namespace)::'. I've got a better solution working on
carlton_dictionary_branch.
>Release-Note:
>Audit-Trail:
>Unformatted: