digitalmars.D.bugs - [Issue 1975] New: void func return value not checked
- d-bugmail puremagic.com (19/19) Apr 05 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1975
- Jarrett Billingsley (6/24) Apr 05 2008 It's legal for various reasons, the main one being templated programming...
- d-bugmail puremagic.com (12/12) Apr 06 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1975
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 digitalmars.com ReportedBy: someanon yahoo.com should raise a warning/ or error: $ cat voidreturn.d void f() { return 1; } $ dmd -c -w voidreturn.d --
Apr 05 2008
<d-bugmail puremagic.com> wrote in message news:bug-1975-3 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 digitalmars.com ReportedBy: someanon yahoo.com should raise a warning/ or error: $ cat voidreturn.d void f() { return 1; } $ dmd -c -w voidreturn.dIt'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.
Apr 05 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1975 matti.niemenmaa+dbugzilla iki.fi changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- This is quite intentional. http://digitalmars.com/d/2.0/statement.html#ReturnStatement says: "Expression is allowed even if the function specifies a void return type. The Expression will be evaluated, but nothing will be returned." --
Apr 06 2008