R
Ralf Goertz
Hi,
I am desperate. I have a huge program using boost:ython which crashes
when called from python but which runs fine, when called via main().
While trying to find the problem I encountered an even weirder problem.
Then I tried to write a short program that exhibits the problem, but
that problem vanishes, i.e. the short program behaves as expected but
the big one doesn't. Here is the short one:
#include <iostream>
#include <vector>
using namespace std;
struct foo;
struct Bar {
void bar(const foo &) {
}
};
vector<vector<const foo*> >v;
struct foo { };
int main() {
foo f;
Bar b;
v.push_back(vector<const foo * >(1,&f));
b.bar(*v.back().back()); // (*)
return 0;
}
This compiles. But when I omit the dereferencing in the marked line the
compiler complains (as it should):
error: no matching function for call to 'Bar::bar(const foo*&)'
The problem is: in the big program I do exactly the same. But here the
program compiles *whether* *or* *not* I dereference. How can that be?
The (main()-called) program crashes when compiled without dereferencing
and works fine otherwise. The python called version crashes in both
cases. Every crash happens after the program has already stepped over
the marked line without problem and without producing wrong results.
I am puzzled. What's going on?
I am desperate. I have a huge program using boost:ython which crashes
when called from python but which runs fine, when called via main().
While trying to find the problem I encountered an even weirder problem.
Then I tried to write a short program that exhibits the problem, but
that problem vanishes, i.e. the short program behaves as expected but
the big one doesn't. Here is the short one:
#include <iostream>
#include <vector>
using namespace std;
struct foo;
struct Bar {
void bar(const foo &) {
}
};
vector<vector<const foo*> >v;
struct foo { };
int main() {
foo f;
Bar b;
v.push_back(vector<const foo * >(1,&f));
b.bar(*v.back().back()); // (*)
return 0;
}
This compiles. But when I omit the dereferencing in the marked line the
compiler complains (as it should):
error: no matching function for call to 'Bar::bar(const foo*&)'
The problem is: in the big program I do exactly the same. But here the
program compiles *whether* *or* *not* I dereference. How can that be?
The (main()-called) program crashes when compiled without dereferencing
and works fine otherwise. The python called version crashes in both
cases. Every crash happens after the program has already stepped over
the marked line without problem and without producing wrong results.
I am puzzled. What's going on?