Thread overview
bobef
Jan 30, 2005
Walter
incorrect detection of function not returning value
Jan 30, 2005
bobef
Jan 30, 2005
Walter
incorrect detection of function not returning value 2
Jan 30, 2005
bobef
January 29, 2005
In this case D compiler does not detect that function does not return
and if it comes to the end program crashes with access violation or something
like that...

long z()
{
if(1 || 2 || 3) return 0;
}


January 30, 2005
"incorrect detection of function not returning value" <incorrect_member@pathlink.com> wrote in message news:cth7pe$mr7$1@digitaldaemon.com...
> In this case D compiler does not detect that function does not return and if it comes to the end program crashes with access violation or
something
> like that...
>
> long z()
> {
> if(1 || 2 || 3) return 0;
> }

The example program will never run off the end, which is why the compiler cannot reliably detect such at compile time. But construct an example that will run off the end - the program will throw an exception at runtime. This is as designed.


January 30, 2005
This was the case.
if obj.WindowProc(...) return true program crashes
and compiler did not gave me a warning
I had few more case where I forgot to return but I dont't remeber them...
Probably the looked almost the same...

extern(Windows) LRESULT _g_WindowProc(HWND hWnd, uint uMsg, WPARAM wParam,
LPARAM lParam)
{
akWnd obj=_g_akWnd_map[hWnd];
LRESULT ret=0;
if(!obj || obj.m_handle!=hWnd || !obj.WindowProc(uMsg,wParam,lParam))
ret=DefWindowProcA(hWnd, uMsg, wParam, lParam);
}

In article <cthe2k$t0f$1@digitaldaemon.com>, Walter says...
>
>
>"incorrect detection of function not returning value" <incorrect_member@pathlink.com> wrote in message news:cth7pe$mr7$1@digitaldaemon.com...
>> In this case D compiler does not detect that function does not return and if it comes to the end program crashes with access violation or
>something
>> like that...
>>
>> long z()
>> {
>> if(1 || 2 || 3) return 0;
>> }
>
>The example program will never run off the end, which is why the compiler cannot reliably detect such at compile time. But construct an example that will run off the end - the program will throw an exception at runtime. This is as designed.
>
>


January 30, 2005
A little mistake :)

ret=DefWindowProcA(hWnd, uMsg, wParam, lParam);

should be read as return DefWindowProcA(hWnd, uMsg, wParam, lParam);


January 30, 2005
If you run obj2asm on the .obj file, you should see the code where it throws the exception where the return would have been.

"bobef" <bobef_member@pathlink.com> wrote in message news:ctit57$tb$1@digitaldaemon.com...
> This was the case.
> if obj.WindowProc(...) return true program crashes
> and compiler did not gave me a warning
> I had few more case where I forgot to return but I dont't remeber them...
> Probably the looked almost the same...
>
> extern(Windows) LRESULT _g_WindowProc(HWND hWnd, uint uMsg, WPARAM wParam,
> LPARAM lParam)
> {
> akWnd obj=_g_akWnd_map[hWnd];
> LRESULT ret=0;
> if(!obj || obj.m_handle!=hWnd || !obj.WindowProc(uMsg,wParam,lParam))
> ret=DefWindowProcA(hWnd, uMsg, wParam, lParam);
> }
>
> In article <cthe2k$t0f$1@digitaldaemon.com>, Walter says...
> >
> >
> >"incorrect detection of function not returning value" <incorrect_member@pathlink.com> wrote in message news:cth7pe$mr7$1@digitaldaemon.com...
> >> In this case D compiler does not detect that function does not return and if it comes to the end program crashes with access violation or
> >something
> >> like that...
> >>
> >> long z()
> >> {
> >> if(1 || 2 || 3) return 0;
> >> }
> >
> >The example program will never run off the end, which is why the compiler cannot reliably detect such at compile time. But construct an example
that
> >will run off the end - the program will throw an exception at runtime.
This
> >is as designed.
> >
> >
>
>