[Issue 16454] Return in the body of a foreach in a constructor backed by opApply corrupts the object
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Wed Aug 31 11:14:51 PDT 2016
    
    
  
https://issues.dlang.org/show_bug.cgi?id=16454
ag0aep6g at gmail.com changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g at gmail.com
           Hardware|x86_64                      |All
                 OS|Mac OS X                    |All
--- Comment #1 from ag0aep6g at gmail.com ---
Slightly reduced:
----
struct OpApply {
    int opApply(int delegate(int) cb) { return 0; }
}
struct Bolinha {
    int a = 0;
    this(int dummy) {
        OpApply moviadao;
        foreach(int b; moviadao) return;
    }
}
void main() {
    import std.stdio;
    writeln(Bolinha(0).a);
}
----
Also fails on Linux and Windows (wine).
--
    
    
More information about the Digitalmars-d-bugs
mailing list