Function with try/catch and no return statement

Jacob Carlborg doob at me.com
Sun Feb 7 11:50:00 PST 2010


On 2/6/10 16:19, Don wrote:
> Jacob Carlborg wrote:
>> The following code does not cause a compile error:
>>
>> int foo ()
>> {
>> try
>> int i;
>> catch (Exception)
>> throw new Exception("");
>> }
>>
>> Wouldn't it be quite obvious for the compiler to see that there is no
>> return statement in the above function and give a compile error? The
>> same also happens with scope(failure).
>>
>> Mac OS X 10.5.7 dmd 1.056.
>
> It gives an error for me on Windows when compiled with -w. If it doesn't
> on Mac, that's definitely a bug.

I does give an error if I compile with -w, but I think it should be an 
error even without -w.



More information about the Digitalmars-d mailing list