digitalmars.D.bugs - [Issue 15745] New: Inline Assembly stomped on by Profiling
- via Digitalmars-d-bugs (44/44) Mar 02 2016 https://issues.dlang.org/show_bug.cgi?id=15745
https://issues.dlang.org/show_bug.cgi?id=15745 Issue ID: 15745 Summary: Inline Assembly stomped on by Profiling Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: pontifechs gmail.com I posted this on the learn section of the forum earlier in the week, but I'm reasonably certain this is a compiler bug. Essentially, when I run some code which has inline assembly through the profiler, I get unexpected results. Here's a reproduction: // bsf is Bitscan Forward. It should return the index of the least significant bit which is on. ubyte LS1B(ulong board) { asm { bsf RAX, board; } } void main() { import std.conv; for (int i = 0; i < 63; ++i) { auto slide = (1UL << i); auto ls1b = slide.LS1B; assert(ls1b == i, "Incorrect LS1B ~ expected: " ~ i.to!string ~ " got: " ~ ls1b.to!string); } } If I run the above like so: dmd -debug app.d; ./app It doesn't assert. But if I run it like so: dmd -profile app.d; ./app It asserts, and comes back with a different answer every time. --
Mar 02 2016