www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6423] New: Garbage is returned from `void main()`

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6423

           Summary: Garbage is returned from `void main()`
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



---
No `xor eax,eax` instruction added by dmd v1.069/v2.054 so the program returns
garbage:

void f(){}

void main() {
    return f();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 01 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6423


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx



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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6423


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc





 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6423




OK. Then it's purely just a wrong-code bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 27 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6423


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw ubuntu.com





 
 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 27 2013