Summary: Wrong Code With Scope Exit + By-Ref Parameters
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        Depends on: 6955

--- Comment #0 from David Simcha <> 2011-11-16 18:12:10 PST ---
The following code was reduced from std.conv.  It prints "BAD!!!" only with -O
enabled.  Since parse() gets rid of the entire contents of v, v.length should
be zero upon exiting toImpl and nothing should be printed.

import core.stdc.stdio;

T toImpl(T)(immutable string value)
    string v = value;  

        if (v.length)
    return parse!T(v);

T parse(T)(ref string value) 
    value = value[0..0];
    return 666;

void main() 
    immutable s = "42";

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to