HOW can THIS cause an error?

Started by
43 comments, last by RunningInt 18 years, 5 months ago
if(yppf<=0.0f && yppf>=-10.0f); I do this in my main loop (it does nothing right now because I took everything out to debug it). My program runs for thousands of frames doing this comparison every frame and then will error out at roughly the same point each time (the point that the error occurs is within a few hundred frames each time). The error says: "The instruction at "[some address in hex]" referenced memory at "[some other address in hex]". The memory could not be "written". yppf is a float value. I have changed the code so that it remains the same (0) throughout and doesn't do anything and the program will still fail at roughly the same point. Commenting out this line will make the program run fine... WTF!
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
Advertisement
Have you tried running the program in a debugger?

Anyway, you didn't exactly provide a lot of details to go on, so I doubt anyone can really help you. One line of code seems harmless enough, but what about the rest of your program? What are the hex addresses it reports in the error? what happens before/after this line?
is the ; intentional? ;)
You don't need any more details, i said that I changed the code so that that variable is constant and NEVER referenced, other than in that if statement. I tried setting is as a constant so that both true and false would result from the if statement (not at the same time, lol). If you are seeing the ONLY point it is used in the program and you know that the program runs fine without that line of code, EVERYTHING ELSE BEING THE SAME, why do you need to know more about the program?
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
Quote:Original post by toucel
is the ; intentional? ;)


yes, and that is perfectly fine C++. I obviously had something there but removed it to debug it. Doing nothing, that comparison will create an error, even when the variable it is comparing is constant and never even used by the program, AND even after the program has run for ~45 seconds and that comparison has been evaluated thousands of times.
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
Quote:why do you need to know more about the program?
We need to know more about the program since that line does not look like it can cause an error, so the real cause is probably elsewhere.
Quote:Original post by bakery2k1
We need to know more about the program since that line does not look like it can cause an error, so the real cause is probably elsewhere.


Exactly, but the real case is not elsewhere, I do absolutely nothing with the variable being compared, and without that line the program runs fine.

codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
Statements in a program do not run in isolation. If your program is anything more than:

int main(){float yppf = 0x0f;if(yppf<=0.0f && yppf>=-10.0f);return 0;}


Then the error is probably elsewhere.
Quote:Original post by CHollman82
You don't need any more details

Oh, that's nice. The person who *can't* find the error is telling people that they don't need more details to spot it? I suppose you know what the error is, and you're just testing us?

Oh, wait, or maybe you just shouldn't make assumptions when debugging.
I just tested your code. if your claims are true that the program does nothing else, and that yppf is a float with the constant value 0.0, then it runs perfectly, and has done so for a few billion iterations here now.

That leads me to the completely crazy guess that there must be something else in your program that interacts with it, making it crash.

Please, when you don't know what the problem is, and ask others for help, don't try to tell them that they don't need to see your program to fix the problem.

Quote:
If you are seeing the ONLY point it is used in the program and you know that the program runs fine without that line of code, EVERYTHING ELSE BEING THE SAME, why do you need to know more about the program?

Because based on the information you've given us, the program works perfectly.
Which means there's something important you haven't mentioned.

Edit:
For the record, here's the program I tested with:
int main(){	float yppf = 0.0;	while (true)		if(yppf<=0.0f && yppf>=-10.0f);}

It has run for 5 minutes now, without crashing. Maybe I'm crazy, but this leads me to think that this line of code in isolation is not the problem.

This topic is closed to new replies.

Advertisement