[Issue 9309] New: Regression (2.061): -O -release generates wrong code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 12 17:29:47 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9309

           Summary: Regression (2.061): -O -release generates wrong code
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: coffimplib
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-12 17:29:46 PST ---
Reduced from Issue 9307:

import std.exception;
import std.stdio;

pure nothrow
private string escapeShellArguments()
{
    char[] buf;

    @safe nothrow
    char[] allocator(size_t size)
    {
        return buf = new char[size];
    }

    escapeShellArgument!allocator("foo");
    return assumeUnique(buf);
}

@safe nothrow
auto escapeShellArgument(alias allocator)(in char[] arg)
{
    auto buf = allocator(4);
    buf[0] = 'f';
    buf[1] = 'o';
    buf[2] = 'o';
    buf[3] = '\0';
}

void main(string[] args)
{
    string res = escapeShellArguments();
    writeln(res);
}

$ dmd test.d && test.exe
> foo

$ dmd test.d -release -O && test.exe
>

If you remove the @safe nothrow and pure attributes the bug goes away. Cannot
reproduce in 2.060, so this is a regression.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list