Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Find declaration/implementation of fails on obects in containers

(1/2) > >>

logzero:
Hi

Not sure if this is a bug, maybe a feature? ;)

Running codeblocks nightly builds on windows. The issue has been there as long as I can remember(2 years?) but too infrequent/random to care until now.

The find function will fail as soon as the object accessed is in a container.


--- Code: ---#include <list>

class bar
{
void foo() {}
};

int main()
{
std::list<bar> foobar;
foobar.insert(bar());
foobar.begin().foo(); // fails to find declaration/implementation

bar bar1;
bar1.foo(); // works fine

    return 0;
}
--- End code ---

zabzonk:
That code won't remotely compile. Was it so hard to try compiling it before posting here? This will:


--- Code: ---#include <list>

struct bar {
void foo() {}
};

int main() {
std::list< bar> foobar;
foobar.push_back(bar());
foobar.begin()->foo();
bar bar1;
bar1.foo();
}
--- End code ---

You are right that trying to find the declaration of foo() via:


--- Code: --- foobar.begin()->foo();
--- End code ---

won't work - I assume it's because it takes too much knowledge of what begin() returns. Interestingly, declaring a function like this:


--- Code: ---bar * f() {
return new bar;
}
--- End code ---

and using:


--- Code: ---f()->foo();
--- End code ---

will work, but it won't if f() is a template function, so I guess template parsing or the lack of it is the issue.



logzero:
Yeah, have been rather sloppy. Sorry and thanks for the corrections.

I was looking for the declaration/implementation of bar method foo() obviously(or not?).

Is the successful compilation a requirement for the functionality to work? Doesn't seem so.

jarod42:
Note that operator -> is more complicated that a simple function...

but it seems not be the problem since

--- Code: ---(*foobar.begin()).
--- End code ---
doesn't complete neither (Release version).

ollydbg:
I can confirm the bug, but fixing it is quite complex. The reason is that our parser can not handle template information correctly. Any good suggestions are welcome.

Navigation

[0] Message Index

[#] Next page

Go to full version