I isolated the lines by adding a
cout <<line number <<endl;
every other line and then commenting out any line that caused the problem. |
The problem is... the line you commented out is a continue statement. Which means it might not be that line that is causing the segfault.. but it might be the fact that you are skipping the rest of the loop body in that iteration that's causing the segfault.
Regardless.... cout statements are a poor man's debugger. If you run this in an
actual debugger, when the segfault occurs, the debugger will automatically snap on the exact line that it occurs on... at which point you will be able to examine the contents of all variables to see exactly why it segfaulted.
also, it has trouble with boolean conditions so
if (boolvar==False){continue;}
also is a problem |
There is no way this is causing a segfault. The only chance is if 'boolvar' is a member and you have a bad 'this' pointer. That is literally the only way this could possibly screw up on you.
And if the 'this' pointer is the culprit, then this line of code is
not where the problem is. The problem would be where you assign the this pointe (ie: when you call the member function -- the object you're giving it must be a bad pointer/incomplete object).
But really I'm just taking shots in the dark here. As others have said you simply have not provided enough info. Your method of isolating the problem is 'iffy' and you probably have not actually found the code that's causing the issue yet. And unless we can see more of the code, none of us are going to be able to find it either.
My advice:
- get rid of your cout statements.
- run the program in a debugger
- reproduce the segfault.
- Post the actual message you get when the program crashes (sometimes they have useful info that you might not realize is useful)
- go in the debugger during the segfault, post the line of code causing the problem (as well as the lines above/below it... ideally post the entire function).
- Look in the debugger's "watch" window
- Post the contents of all the variables involved in that line of code. So if the line of code looks like this:
Post the contents of:
- foobar (or &foobar[0])
- baz
- boop
- foobar[baz]
- this
Once you have that info, it'll be clearly obvious why it's segfaulting.