This is the mail archive of the gdb-patches@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]

Re: [patch] fix for c++/2416


Daniel Jacobowitz wrote:
On Wed, Feb 27, 2008 at 01:03:26PM -0500, Aleksandar Ristovski wrote:
Hello,

As described in the bug report 2416, the problem is with casting to a reference. The attached patch should fix this.

/* You can't cast to a reference type. See value_cast_pointers instead. */ gdb_assert (code1 != TYPE_CODE_REF);

Is casting to a reference type useful, or should we have issued an
error instead?  C++ does not permit this.
Not sure what you mean by "C++ does not permit this"...

This is valid:

void testCast1 (IP::base & arg) {
  IP::derived &ader = (IP::derived &)arg;
  cout << "Test the casting\n";
  ader.foo();
}


The new error is incorrect, which does suggest some missing tests. You can cast from a reference type; value_cast follows references, so an int is just like an int &.

Like Michael, I don't understand the value.c changes.  Could you
explain them?

I replied to that.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]