[Bug 180] New: DMD accepts a function with a non-void return type but no return statements

Derek Parnell derek at psych.ward
Wed Jun 7 15:11:04 PDT 2006


On Thu, 08 Jun 2006 02:01:22 +1000, Stewart Gordon <smjg_1998 at yahoo.com>  
wrote:

> Derek Parnell wrote:
>> On Wed, 07 Jun 2006 22:19:47 +1000, <d-bugmail at puremagic.com> wrote:
>>
>>> As such, the compiler should be reporting an error on such code as the  
>>> above.
>>  This is one of the 'optional' errors.
>
> To me, there's no such thing as an "'optional' error".  An error is an  
> error, and a warning is a warning.  Errors must always be reported, and  
> warnings may or may not be reported depending on the compiler and how  
> it's been configured.
>
> To have at least one return statement in a function with a non-void  
> return type is a requirement written into the spec.  Violating such  
> requirements is _always_ an error.
>
>> You can get the compiler to issue an error by using the -w switch.
>
> -w enables warnings.  The warning that's semi-relevant is that some path  
> through the function doesn't return, which isn't quite the same as a  
> function having no return statements at all.

I'm sorry if I gave the impression that I was defending DMD on this issue.  
Personally I think that Walter's approach is quite daft and lacks  
consistency and reason. However, I'm making the generous assumption that  
this is one of the things that is quite low on his todo list and its just  
a matter of time for him to correct the situation.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d-bugs mailing list