GDB can't parse variables named "memory" or "array"?

Paul Smith <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
I've tried this with lots of different versions of GDB (7.7.1, 7.11,
7.12, etc.), and none of them work when debugging my programs (not just
my main program but all my unit tests as well):

  (gdb) p memory
  A syntax error in expression, near `'.

  (gdb) p array
  A syntax error in expression, near `'.

Note I don't even have to start the program to see this (but of course
it always happens, when debugging live processes, cores, etc.)

It's only "array" and "memory" (as far as I can tell); other variables
work fine.  Also, it fails even for class members named "array" or
"memory", not just simple variables (e.g., "p obj.array" fails as
well).  I'm starting GDB with -n to avoid any init files being loaded
etc.

Nothing I can do will let this work; I tried things like:

  (gdb) p/r array
  A syntax error in expression, near `'.

  (gdb) set $a = array
  A syntax error in expression, near `'.

However, I've tried to create simple repro cases and even when compiled
with identical flags, those work fine so it's something about my
program(s), or maybe some library I'm linking.

If I rename the variable to something else, then GDB will print it just
fine.

Any ideas about what can I do to try to figure out what's happening
here?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.