Bug 15207 – [REG2.069.0-b1] Wrong codegen with -inline

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-15T15:47:00Z
Last change time
2015-10-23T01:56:49Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
aliloko

Comments

Comment #0 by aliloko — 2015-10-15T15:47:41Z
Compiler: v2.069.0-b2, x86 arch To reproduce: compile with dmd -inline main.d This bug disappear when -inline is removed. ---------------------------------------------->8------------ struct vec3f { float x, y, z; this(float x_, float y_, float z_) { x = x_; y = y_; z = z_; } vec3f clone() { vec3f res = this; return res; } } class AnnoyingRegression { vec3f a; this() { a = vec3f(1, 2, 3).clone; // Writes nan nan nan if -inline switch // Writes 1 2 3 if no -inline switch import std.stdio; writefln("%s %s %s", a.x, a.y, a.z); } } void main(string[]args) { new AnnoyingRegression(); } ---------------------------------------------->8------------
Comment #1 by dlang-bugzilla — 2015-10-16T13:55:16Z
Comment #2 by k.hara.pg — 2015-10-20T13:08:26Z
Comment #3 by github-bugzilla — 2015-10-21T09:50:23Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3224f462eacbcd2d1cab663ea2af1e46d8bfd6fd fix Issue 15207 - Wrong codegen with -inline When issue 14944 fixed, the ref variable content initializing form had been flagged by `MemorySet.refValueInit`. However, inilining may replace `AssignExp.e1` operand with a `STCref` temporary variable. When it happens, the `MemorySet.refValueInit` flag will be ignored in `AssignExp.toElem` and wrong code had generated. To avoid the issue, instead flag the case "ref varaible initialization" by `MemorySet.referenceInit`. Its meaning will be kept beyond inlining stage, and the bug won't happen. https://github.com/D-Programming-Language/dmd/commit/77463d7b0503a96d0ea367f5f29df15ed7655cad Merge pull request #5206 from 9rnsr/fix15207 [REG2.069.0-b1] Issue 15207 - Wrong codegen with -inline
Comment #4 by aliloko — 2015-10-21T11:54:20Z
Much thanks!
Comment #5 by github-bugzilla — 2015-10-23T01:56:49Z