[Issue 1975] New: void func return value not checked

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Apr 5 15:00:46 PDT 2008


<d-bugmail at puremagic.com> wrote in message 
news:bug-1975-3 at http.d.puremagic.com/issues/...
> http://d.puremagic.com/issues/show_bug.cgi?id=1975
>
>           Summary: void func return value not checked
>           Product: D
>           Version: 2.012
>          Platform: PC
>        OS/Version: Linux
>            Status: NEW
>          Severity: normal
>          Priority: P2
>         Component: DMD
>        AssignedTo: bugzilla at digitalmars.com
>        ReportedBy: someanon at yahoo.com
>
>
> should raise a warning/ or error:
>
> $ cat voidreturn.d
> void f() {
>  return 1;
> }
>
> $ dmd -c -w voidreturn.d

It's legal for various reasons, the main one being templated programming. 
It avoids special-casing returns for void functions.  I've used it more than 
once.  If a function is 'void', then "return x" is basically the same as "x; 
return", as long as x can be evaluated. 




More information about the Digitalmars-d-bugs mailing list