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++/16117] New: filename blocks variable of the same name


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

            Bug ID: 16117
           Summary: filename blocks variable of the same name
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: jan.kratochvil at redhat dot com
            Blocks: 16106

Practical example of accidentally using variable "valarray":

# g++ -o reprofull reprofull.C -Wall -g $(pkg-config --cflags --libs
cairomm-1.0)
(gdb) l
1       #include <cairomm/context.h>
2       class C {
3       public:
4         int valarray[1];
5         void m() {} /* line 5 */
6       };
7       int main() {
8         C c;
9         c.m();
10      }
(gdb) b 5
Breakpoint 1 at 0x4006c4: file reprofull.C, line 5.
(gdb) r
Breakpoint 1, C::m (this=0x7fffffffd810) at reprofull.C:5
5         void m() {} /* line 5 */
(gdb) p valarray
A syntax error in expression, near `'.
(gdb) _

Minimal reproducer is:


(gdb) l
1       #include "includefile"
2       class C {
3       public:
4         int includefile[1];
5         void m() {} /* line 5 */
6       };
7       int main() {
8         C c;
9         c.m();
10      }
(gdb) l includefile:1
1       int unusedvar;
(gdb) b 5
(gdb) r
Breakpoint 1, C::m (this=0x7fffffffd810) at repromin.C:5
5         void m() {} /* line 5 */
(gdb) p includefile
A syntax error in expression, near `'.
(gdb) set debug parser 1
(gdb) p includefile
Starting parse
Entering state 0
Reading a token: Next token is token FILENAME ()
Shifting token FILENAME ()
Entering state 46
Reducing stack by rule 101 (line 865):
   $1 = token FILENAME ()
-> $$ = nterm block ()
Stack now 0
Entering state 56
Reading a token: Now at end of input.
A syntax error in expression, near `'.
(gdb) _

This can be hit because C++ include files have no .h extension.

-- 
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]