main return value, struct padding

Denis Koroskin 2korden+dmd at gmail.com
Tue Jan 20 10:54:48 PST 2009


Jarrett Billingsley Wrote:

> On Tue, Jan 20, 2009 at 12:21 PM, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
> > So it appears it returns 0 unless you return something else (!)
> 
> Ha!

Yes (but not always), even though specs clearly say that void functions evaluate return values and discard them.

IIRC, this one returns 0:

void main() { 
    return new Object();
}

while this one returns an object address:

void foo() { return new Object(); }

void main() {
    return foo();
}


More information about the Digitalmars-d-learn mailing list