function not returning anything

Jarrett Billingsley kb3ctd2 at yahoo.com
Thu Mar 20 20:09:13 PDT 2008


"Saaa" <empty at needmail.com> wrote in message 
news:frv4ov$29n3$1 at 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.. 




More information about the Digitalmars-d-learn mailing list