[patch] fix for c++/2416

Daniel Jacobowitz drow@false.org
Tue Apr 1 17:06:00 GMT 2008


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



More information about the Gdb-patches mailing list