This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] fix for c++/2416
- From: Daniel Jacobowitz <drow at false dot org>
- To: Aleksandar Ristovski <ARistovski at qnx dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 1 Apr 2008 11:53:47 -0400
- Subject: Re: [patch] fix for c++/2416
- References: <47F255CC.4000704@qnx.com>
On Tue, Apr 01, 2008 at 11:33:32AM -0400, Aleksandar Ristovski wrote:
> I believe we should.
>
> Here is a dummy c++ program where this is done explicitly:
>
> #include <iostream>
> using namespace std;
> int main ()
> {
> int a = 42;
> int &refa = (int &)a; // cast not needed, yet compiler doesn't complain.
> cout << refa << endl;
> return 0;
> }
I had to ask two C++ experts what this meant and let them argue about
it for a little while... it's even legal if a is a double. This is
*reinterpret_cast<int *>(&a), an lvalue of type int. That's not what
GDB will do with it, but it's close enough for now.
If you'll delete the extra blank line, the patch and testcases are OK.
Thanks for your patience.
--
Daniel Jacobowitz
CodeSourcery