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 python/21308] New: Cannot get non-type template argument if it is a const-qualified member pointer


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

            Bug ID: 21308
           Summary: Cannot get non-type template argument if it is a
                    const-qualified member pointer
           Product: gdb
           Version: 7.12.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: freddie_chopin at op dot pl
  Target Milestone: ---

Source code:

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

struct C { int a; };

template<const int C::* Pointer>
struct D {};

int main()
{
        D<&C::a> d;
        return 0;
}

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

It's not possible to get non-type template argument with Python API if it is a
const-qualified member pointer. Any attempt results in "RuntimeError: Template
argument is optimized out". See log for details:

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

$ g++ -g -ggdb3 gdb.cpp 
$ gdb ./a.out 
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...done.
(gdb) b main
Breakpoint 1 at 0x4004ca: file gdb.cpp, line 9.
(gdb) run
Starting program: /home/freddie/test/a.out 

Breakpoint 1, main () at gdb.cpp:9
9               return 0;
(gdb) python
print(gdb.selected_frame().read_var('d').type.template_argument(0))
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Template argument is optimized out
Error while executing Python code.
(gdb) 

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

If I remove "const" from the template (so "template<int C::* Pointer>", nothing
more changed), it works fine:

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

...
(gdb) python
print(gdb.selected_frame().read_var('d').type.template_argument(0))
&C::a

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --

Any ideas whether it's a bug or maybe I'm doing something wrong?

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