public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19068] New: gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined
@ 2015-10-05 18:11 richard_sharman at mitel dot com
  2015-10-05 18:12 ` [Bug c++/19068] " richard_sharman at mitel dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: richard_sharman at mitel dot com @ 2015-10-05 18:11 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 19068
           Summary: gdb cannot handle operator= if both const access (as
                    rhs) and non-const (lhs) methods defined
           Product: gdb
           Version: 7.10
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: richard_sharman at mitel dot com
  Target Milestone: ---

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/19068] gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined
  2015-10-05 18:11 [Bug c++/19068] New: gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined richard_sharman at mitel dot com
@ 2015-10-05 18:12 ` richard_sharman at mitel dot com
  2015-10-05 18:13 ` richard_sharman at mitel dot com
  2023-12-27 16:46 ` ssbssa at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: richard_sharman at mitel dot com @ 2015-10-05 18:12 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Richard Sharman <richard_sharman at mitel dot com> ---
Created attachment 8681
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8681&action=edit
Simple file to demonstrate the problem

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/19068] gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined
  2015-10-05 18:11 [Bug c++/19068] New: gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined richard_sharman at mitel dot com
  2015-10-05 18:12 ` [Bug c++/19068] " richard_sharman at mitel dot com
@ 2015-10-05 18:13 ` richard_sharman at mitel dot com
  2023-12-27 16:46 ` ssbssa at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: richard_sharman at mitel dot com @ 2015-10-05 18:13 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Richard Sharman <richard_sharman at mitel dot com> ---
If a class is defined with a single operator[] method,
then gdb can invoke this method with the normal x[i] syntax.

If, however,  there are separate const "rhs" and non-const "lhs" 
methods defined,  then trying to print or assign using x[i] syntax
produces the message "Could not find operator[].".

See example t.c.  When compiled as is (SEPARATE_SUB_METHODS defined)
there are methods 
        const T& operator[](const int index) const 
and
        T& operator[](const int index) {

Running gdb shows:

(gdb) b 53
Breakpoint 1 at 0x40076a: file t.cc, line 53.
(gdb) r
(gdb) p x
$1 = {storage = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}}
(gdb) p x[3]
Could not find operator[].
(gdb) show version
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.


When SEPARATE_SUB_METHODS is undefined there is only one method
        T& operator[](const int index)  {
and gdb works fine with this:

(gdb) b 53
Breakpoint 1 at 0x40076a: file t2.cc, line 53.
(gdb) r
Starting program: /localhome/sharman/tmp/c++test/t2 

Breakpoint 1, main (NameError: Installation error: gdb.execute_unwinders
function is missing

argc=1, argv=0x7fffffffdbc8) at t2.cc:53
53              printf("%2d: %d\n", i, x[i]);
(gdb) p x
$1 = {storage = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}}
(gdb) p x[3]
NameError: Installation error: gdb.execute_unwinders function is missing
$2 = (int &) @0x7fffffffdab8: 30
(gdb) set var x[3] = 33
(gdb) p x[3]
$3 = (int &) @0x7fffffffdab8: 33
(gdb) p x
$4 = {storage = {10, 20, 33, 40, 50, 60, 70, 80, 90, 100}}
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/19068] gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined
  2015-10-05 18:11 [Bug c++/19068] New: gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined richard_sharman at mitel dot com
  2015-10-05 18:12 ` [Bug c++/19068] " richard_sharman at mitel dot com
  2015-10-05 18:13 ` richard_sharman at mitel dot com
@ 2023-12-27 16:46 ` ssbssa at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: ssbssa at sourceware dot org @ 2023-12-27 16:46 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
                 CC|                            |ssbssa at sourceware dot org
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |8.0

--- Comment #3 from Hannes Domani <ssbssa at sourceware dot org> ---
Works since version gdb-8.0.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-27 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-05 18:11 [Bug c++/19068] New: gdb cannot handle operator= if both const access (as rhs) and non-const (lhs) methods defined richard_sharman at mitel dot com
2015-10-05 18:12 ` [Bug c++/19068] " richard_sharman at mitel dot com
2015-10-05 18:13 ` richard_sharman at mitel dot com
2023-12-27 16:46 ` ssbssa at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).