view tests/mini/foreach10.d @ 1612:081c48283153

Merge DMD r278: bugzilla 370 Compiler stack overflow on recursive... bugzilla 370 Compiler stack overflow on recursive typeof in function declaration. --- dmd/expression.c | 1 + dmd/mtype.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:21 -0300
parents 8baf611f0009
children
line wrap: on
line source

module foreach10;

extern(C) int printf(char*, ...);

void main() {
    char* last = null;
    printf("The addresses should increment:\n");
    foreach (ref c; "bar") {
        auto a = {
            printf("%x '%c'\n", c, c);
            return &c;
        };
        auto nw = a();
        printf("ptr = %p\n", nw);
        if (last != null)
            assert(nw == last+1);
        last = nw;
    }
}