Bug 6506 – OS X: wrong value is passed to simple argument along with a delegate with -O

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-08-16T10:58:00Z
Last change time
2011-08-16T18:50:20Z
Keywords
wrong-code
Assigned to
nobody
Creator
kennytm

Comments

Comment #0 by kennytm — 2011-08-16T10:58:09Z
---------------------------- void enforce6506(bool condition, lazy int m) { assert(!condition); } void toImpl6506(int value) { enforce6506(value >= 0, 4); } void bug6506() { toImpl6506(-112345); } void main() { bug6506(); } ---------------------------- $ dmd -unittest -release -O z.d $ ./z core.exception.AssertError@z(2): Assertion failure ... ---------------------------- The bug _does_not_ appear when: - one of '-unittest', '-release', and '-O' doesn't exist. - the type of 'condition' is not 'bool', 'u?(byte|short|int)' and '[wd]?char'. - the 'lazy' argument doesn't exist. This bug is preventing OS X from passing Phobos' unit test in the release build after fixing bug 6377. See also https://github.com/D-Programming-Language/phobos/commit/994d76fe.
Comment #1 by kennytm — 2011-08-16T11:50:31Z
Correction: 1. Only -O is needed. 2. It's not 'lazy' causing the bug, but passing a nested delegate. ------------------------------- void enforce6506b(bool condition, void delegate() m) { assert(!condition); } void toImpl6506b(int value) { void f(){} enforce6506b(value >= 0, &f); } void bug6506b() { toImpl6506b(-112345); } void main() { bug6506b(); } ------------------------------- $ dmd -O z.d $ ./z core.exception.AssertError@z(2): Assertion failure ... -------------------------------
Comment #2 by bugzilla — 2011-08-16T18:50:20Z
The bug is actually there on all platforms (it's a scheduler problem), it just fails in a way that doesn't show on the others. https://github.com/D-Programming-Language/dmd/commit/7ce30cbf691d9adb377da273ca5fe465dd00ff41 https://github.com/D-Programming-Language/dmd/commit/564a2d0a0a1cb52b2536d00cd364b0a3502f302e