digitalmars.D.bugs - [Issue 14480] New: dmd 2.067 x64 release codegen
- via Digitalmars-d-bugs (76/76) Apr 22 2015 https://issues.dlang.org/show_bug.cgi?id=14480
https://issues.dlang.org/show_bug.cgi?id=14480 Issue ID: 14480 Summary: dmd 2.067 x64 release codegen Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: fengli gmail.com Created attachment 1515 --> https://issues.dlang.org/attachment.cgi?id=1515&action=edit bad rendering Something very weird happened to my 2D vector graphics library since upgrading to 2.067. I'm not 100% sure but it looks more like a codegen issue than a program error. This is because both 32 bit debug and release builds are good, 64 bit debug build is good, but 64 bit release build is broken. good rendering https://onedrive.live.com/redir?resid=FDD337136ADE2BCF!11348&authkey=!AHIhJQXNT77Ewg8&v=3&ithint=photo%2cpng bad rendering https://onedrive.live.com/redir?resid=FDD337136ADE2BCF!11349&authkey=!ALVOTsEIN6qFvJs&v=3&ithint=photo%2cpng I tracked down this issue to the bezier curve division routine: void bezier(T)(in T p1, in T p2, in T p3, in T p4) { auto p12 = (p1 + p2) / 2; auto p23 = (p2 + p3) / 2; auto p34 = (p3 + p4) / 2; auto p123 = (p12 + p23) / 2; auto p234 = (p23 + p34) / 2; auto p1234 = (p123 + p234) / 2; auto d = p4-p1; auto d2 = fabs(((p2.x - p4.x) * d.y - (p2.y - p4.y) * d.x)); auto d3 = fabs(((p3.x - p4.x) * d.y - (p3.y - p4.y) * d.x)); if((d2 + d3)*(d2 + d3) < 0.25 * dot(d, d)) { m_appender ~= [PathVertex(p1234, VertexAttr.LineTo)]; return; } bezier(p1, p12, p123, p1234); bezier(p1234, p234, p34, p4); } It's pretty straightforward, if the curve is flat enough then return, otherwise divide the curve into 2 shorter curves. Below is a trace of the recursive division of one of the curves: good: [563.022, 319.849] [534.772, 266.534] [551.44, 365.862] [551.44, 365.862] [563.022, 319.849] [548.897, 293.192] [546.001, 304.695] [546.637, 322.862] [563.022, 319.849] [555.96, 306.52] [551.704, 302.732] [549.294, 304.546] [563.022, 319.849] [559.491, 313.185] [556.661, 308.905] [554.414, 306.519] [563.022, 319.849] [561.257, 316.517] [559.666, 313.781] [558.237, 311.58] [558.237, 311.58] [556.807, 309.379] [555.538, 307.712] [554.414, 306.519] ... bad: [563.022, 319.849] [534.772, 266.534] [551.44, 365.862] [551.44, 365.862] [563.022, 319.849] [548.897, 293.192] [546.001, 304.695] [546.637, 322.862] [563.022, 319.849] [555.96, 306.52] [551.704, 302.732] [549.294, 304.546] [563.022, 319.849] [559.491, 313.185] [556.661, 308.905] [554.414, 306.519] [563.022, 319.849] [561.257, 316.517] [559.666, 313.781] [558.237, 311.58] [558.237, 311.58] [556.807, 309.379] [555.538, 307.712] [9.0195e-318, 9.02709e-318] <-- WTF? ... As you can see the last point becomes a very small number. Consider this is the 'p4' argument which is not calculated but directly passed down, how can this be? If you want to see the full code, here it is https://github.com/finalpatch/dagger And the broken program is demo/svg --
Apr 22 2015