help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: not resolving operator []


From: Guy Harrison
Subject: Re: not resolving operator []
Date: Thu, 23 Sep 2004 01:59:56 GMT
User-agent: KNode/0.7.7

Edo wrote:

> Hello
> 
> I don?t know why the code below is giving the message it does when I
> (gdb)it.
> 
> vector<double> vd;
> add few elements to vd
> 
> int r = 2;
> vector<int> pv;
> for(int i = 0; i<= 1; ++i){
>      int x = static_cast<int> (floor(vd[i]*r));
>      pv.push_back(x);
> }
> 
> 
> when the line "pv.push_back(x);" is executed at least once, I am getting
> this
> (gdb) p pv[0]
> One of the arguments you tried to pass to operator[] could not be
> converted to what the function wants.
> (gdb) p vd[0]
> $4 = (double &) @0x80709c8 .273365000000000002
> 
> ok, I thought reinterpret_cast<int> instead of static_cast<int> but that
> would not even compile.
> I am using GNU 6.1-debian
> 
> thanks for any suggestions

Sad fact of life is, gdb isn't very good at C++ syntax. Fwiw even those
fancy windows GUI debuggers can flake out in such circumstances.

However, it often helps to use the actual method eg: "vd.operator[](i)" but
as I just discovered gdb doesn't like '[' and I'm not of a mind to figure
out the reason further. Therein lies another clue, chuck some DEBUG
exceptions / logging / "printf" into your code and you'll rarely need to
use gdb so intimately.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]