Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

graveyard filla

what happends if nothing is returned?

This topic is 5227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

high, say i have a funtion, called int Blah(x); now, insidee Blah looks like this:

int Blah(x)
{

if(x == 5)
return 5;

if(x == 10)
return 10;

}

now, obviously not all the control paths return a value, and the compiler will warn me of this. but what will happen if i do this? int z = Blah(7); so what will happen? will the universe instantly implode? or will something magical happen? im guessing some sort of garbage will get put into it, but im not sure. so what does really happen, and if the answer is "garbage", what kind of garbage? what does this garbage look like? thanks for any help

Share this post


Link to post
Share on other sites
Advertisement
actually, I believe that most compilers will silently insert a ''return 0;'' at the end of the function in that case. If they don''t, then yes, you would get garbage.



(Stolen from Programmer One)
UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus

Share this post


Link to post
Share on other sites
quote:
Original post by Mkk
Umh, what´s eax register? :o
AFAIK, there are 4 registers: eax, ebx, ecx, and edx. I don''t know their true purposes, but you use them in Assembly to do calculations.

Share this post


Link to post
Share on other sites
Dragon88: Yea, I got zero as a return value when I did a little test app..


[edited by - Mkk on March 26, 2004 7:11:17 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Mkk
Umh, what´s eax register? :o


registers are small one, two or four byte peices of memory directly inside the processor. That makes them the fastest possible memory, and the most expensive. eax is one of these on an x86 chip that is used to store the return value in the C calling convention.

Share this post


Link to post
Share on other sites
quote:
Original post by Mkk
Dragon88: Yea, I got zero as a return value when I did a little test app..


[edited by - Mkk on March 26, 2004 7:11:17 PM]


Did you make sure to load eax with a bogus value before returning?



(Stolen from Programmer One)
UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus

Share this post


Link to post
Share on other sites

This topic is 5227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!