Bug 9309 – Regression (2.061): -O -release generates wrong code

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-12T17:29:00Z
Last change time
2013-01-13T00:13:06Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
andrej.mitrovich

Comments

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
Comment #5 by k.hara.pg — 2013-01-12T20:30:48Z
Comment #6 by github-bugzilla — 2013-01-12T23:57:15Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a3373759c41931171a5fd023ab7df8e9f1689879 fix Issue 9309 - Regression (2.061): -O -release generates wrong code In current, all nested functions should be weak purity at most. https://github.com/D-Programming-Language/dmd/commit/7686d93349861f83e7c8adc1e0fad0f36f932e64 Merge pull request #1474 from 9rnsr/fix9309 Issue 9309 - Regression (2.061): -O -release generates wrong code