return in void functions

Georg Wrede georg.wrede at iki.fi
Fri Mar 6 01:04:48 PST 2009


bearophile wrote:
> D has safeties to avoid this kind of code, because it's essentially considered a bug:
> 
> int foo() {}
> void main() {
>     foo();
> }
> 
> 
> But this compiles with no errors:
> 
> void foo() {
>     return 1;
> }
> void main() {
>     foo();
> }

No error in C either, only a warning.

This being an easy thing to fix, one would think it'd been fixed ages 
ago already. Therefore, one only assumes there to be a motivation for 
having it like this.



More information about the Digitalmars-d mailing list