Comment #0 by verylonglogin.reg — 2011-08-01T05:06:43Z
No `xor eax,eax` instruction added by dmd v1.069/v2.054 so the program returns garbage:
void f(){}
void main() {
return f();
}
Comment #1 by hsteoh — 2013-08-27T08:16:42Z
Still happens on git HEAD.
I'm guessing perhaps the compiler got confused by returning a void function? I'm not sure code like this should be allowed, as it doesn't really make sense to be able to return void (via a return statement) -- nothing is being returned.
Comment #2 by bearophile_hugs — 2013-08-27T08:20:10Z
(In reply to comment #1)
> I'm guessing perhaps the compiler got confused by returning a void function?
> I'm not sure code like this should be allowed, as it doesn't really make sense
> to be able to return void (via a return statement) -- nothing is being
> returned.
Returning the result of a void function from a void function is accepted by design.
Comment #3 by hsteoh — 2013-08-27T09:42:38Z
OK. Then it's purely just a wrong-code bug.
Comment #4 by ibuclaw — 2013-08-27T10:32:41Z
(In reply to comment #2)
> (In reply to comment #1)
>
> > I'm guessing perhaps the compiler got confused by returning a void function?
> > I'm not sure code like this should be allowed, as it doesn't really make sense
> > to be able to return void (via a return statement) -- nothing is being
> > returned.
>
> Returning the result of a void function from a void function is accepted by
> design.
Aye, but 'void main' is implicitly 'int main' - which is a special case in this instance. ;-)
All other types of void returns are ok to return garbage.