[Bug 180] New: DMD accepts a function with a non-void return type but no return statements
Stewart Gordon
smjg_1998 at yahoo.com
Wed Jun 7 09:01:22 PDT 2006
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.
Stewart.
More information about the Digitalmars-d-bugs
mailing list