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++/17494] New: Ternary operator not evaluated correctly


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

            Bug ID: 17494
           Summary: Ternary operator not evaluated correctly
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: sivachandra at gmail dot com

Consider the following code:

class A
{
public:
  A () { a = 12345; }
  int geta ();

  int a;
};

int
A::geta ()
{
  return a;
}

int
main ()
{
  A a;
  return 0;  /* Break here  */
}

I see this with GDB:

(gdb) p a.geta()
$3 = 12345
(gdb) p false ? a.geta() : 123
$2 = {a = 12345}

The result is of the wrong type (and value).

Similarly:

(gdb) p (true ? 123 : a.geta()) + 1
Can't do that binary op on that type

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