On Sun, 08 May 2011 17:59:02 +0400, Timon Gehr <timon.g...@gmx.ch> wrote:

On page 263, TDPL states that struct objects nested inside a function cannot be returned, because the caller does not have access to their types. Using the auto keyword, DMD lets you do this though. Is this a bug in DMD or an error in
TDPL?


I think that's fine.

On the same page, the assert should be
assert(Local.sizeof == size_t.sizeof + int.sizeof);

rather than
assert(Local.sizeof == 2*size_t.sizeof);

which always fails in 64 bit.


Timon

Without looking at the code, I'd assume that Local is defined something like this:

struct Local
{
        size_t s;
        int i;
}

in which case Local.sizeof would most likely be size_t.sizeof * 2 because of the alignment and implicit padding, i.e 8 bytes on x86, and 16 bytes on x64. size_t.sizeof + int.sizeof only give 12.

I'd agree that this is in fact confusing and needs to be explained.

Reply via email to