www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6506] New: OS X: wrong value is passed to simple argument with a lazy parameter with -unittest -release -O

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6506

           Summary: OS X: wrong value is passed to simple argument with a
                    lazy parameter with -unittest -release -O
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kennytm gmail.com



----------------------------
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6506


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|OS X: wrong value is passed |OS X: wrong value is passed
                   |to simple argument with a   |to simple argument along
                   |lazy parameter with         |with a delegate with -O
                   |-unittest -release -O       |



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
...
-------------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6506


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



18:50:20 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2011