Comment #0 by andrej.mitrovich — 2013-01-12T17:29:46Z
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.
Comment #1 by andrej.mitrovich — 2013-01-12T17:30:20Z
*** Issue 9307 has been marked as a duplicate of this issue. ***
Comment #2 by andrej.mitrovich — 2013-01-12T17:43:16Z
I'm bisecting right now.
Comment #3 by andrej.mitrovich — 2013-01-12T17:44:56Z
(In reply to comment #2)
> I'm bisecting right now.
Git says:
b6a809346a43c7fbf350bd4181d350dd9b2cd4e6 is the first bad commit
Comment #4 by andrej.mitrovich — 2013-01-12T17:46:19Z
(In reply to comment #3)
> (In reply to comment #2)
> > I'm bisecting right now.
>
> Git says:
>
> b6a809346a43c7fbf350bd4181d350dd9b2cd4e6 is the first bad commit
See https://github.com/D-Programming-Language/dmd/pull/1110