Created attachment 8935 [details] c/c++ program to demonstrate the problem GDB cannot print a struct with a field called "thread" if the program is compiled with g++ (not gcc) and with the -m32 option on a x86 system. This is demonstrated by file f.cc. If compiled with gcc with or without -m32 gdb can print x.thread, but if compiled with g++ -m32 it gets the error "A syntax error in expression, near `'." To demonstrate this, source the file Run.sh which shows result of all 4 compilations and the result of gdb executing "print x.thread". For the first 3 cases it prints correctly, "(gdb) $2 = 2" is output. For the 4th case we get "(gdb) A syntax error in expression, near `'." This happens with gcc 4.8 and gcc 5.3, and gdb versions 7.6.1, 7.8 and 7.10. With Hat Enterprise Linux (7.2-64.el6_5.2) there is one extra line of information printed: Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.el6.i686 Attached files: f.cc Commands.gdb Run.sh
Created attachment 8936 [details] GDB script used in Run.sh
Created attachment 8937 [details] Bash script to run the example
This works for me on Fedora 36. Does it still fail for you? I wonder if there is a macro named 'thread' in scope somehow.
Dup. *** This bug has been marked as a duplicate of bug 11927 ***