www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - function not returning anything

reply "Saaa" <empty needmail.com> writes:
byte function(){
..code..
//not returning anything
}


funtion();

After compiling/running it got me:
Error: Win32 exception

Is this correct?
It isn't really easy to debug like that. 
Mar 20 2008
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Saaa" <empty needmail.com> wrote in message 
news:frv4ov$29n3$1 digitalmars.com...
 byte function(){
 ..code..
 //not returning anything
 }


 funtion();

 After compiling/running it got me:
 Error: Win32 exception

 Is this correct?
 It isn't really easy to debug like that.

Compile in non-release mode, and you'll get an error along the lines of "function 'foo' missing return." The reason you get a "Win32 Exception" in release mode is because the compiler will put in an "assert(false, "that error message")" at the end of the function, and when compiled in release mode, "assert(false)"s get turned into an invalid opcode -- hence the exception. It'd be kind of nice if they weren't, or if there were more fine-grained control over what happens to asserts, but..
Mar 20 2008
parent "Saaa" <empty needmail.com> writes:
I don't use -release.

C:\D\Compiler\bud_win_3.04.exe 
ain.d -inline -O -full -cleanup  -DCPATHC:\D\Compiler\D1\dmd\bin -Tmain.exe  
-IC:\D\Compiler\

-inline was the bad guy.

Thanks.


 byte function(){
 ..code..
 //not returning anything
 }


 funtion();

 After compiling/running it got me:
 Error: Win32 exception

 Is this correct?
 It isn't really easy to debug like that.

Compile in non-release mode, and you'll get an error along the lines of "function 'foo' missing return." The reason you get a "Win32 Exception" in release mode is because the compiler will put in an "assert(false, "that error message")" at the end of the function, and when compiled in release mode, "assert(false)"s get turned into an invalid opcode -- hence the exception. It'd be kind of nice if they weren't, or if there were more fine-grained control over what happens to asserts, but..

Mar 20 2008