www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5230] New: ICE(tocsym.c) overriding a method that has an out contract

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

           Summary: ICE(tocsym.c) overriding a method that has an out
                    contract
           Product: D
           Version: D1 & D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: regression
          Priority: P1
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: smjg iname.com


--- Comment #0 from Stewart Gordon <smjg iname.com> 2010-11-17 09:42:46 PST ---
Clearly the implementation of out contract inheritance is broken.

----- override_out_a.d -----
import override_out_b;

class Derived : Base {
    override int method() { return 69; }
}
----- override_out_b.d -----
class Base {
    int method()
    out (r) {}
    body { return 42; }
}
----- DMD 1.065 -----
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd override_out_a.d
override_out_b.d(3): Error: function __ensure forward declaration
linkage = 0
Assertion failure: '0' on line 381 in file 'tocsym.c'

abnormal program termination
----- DMD 2.050 -----
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd override_out_a.d
override_out_b.d(3): Error: function __ensure forward declaration
linkage = 0
Assertion failure: '0' on line 407 in file 'tocsym.c'

abnormal program termination
----------

Compiles successfully if the out contract is removed, or Base and Derived are
defined in the same module.

Adding an out contract to Derived.method doesn't change things.

This has broken SDWF.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5230


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-11-17 11:57:00 PST ---
This was almost certainly caused by the fix to 
bug 3602: ICE(tocsym.c) compiling a class, if its super class has preconditions
Which had almost exactly the same symptoms as this bug (only with __require
instead of __ensure).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5230


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-11-22 06:44:54 PST ---
Exactly the same fix for bug 3602 works here, applied to fensure instead of
frequire:

PATCH: func.c, mergeFensure(), line 1728


    for (int i = 0; i < foverrides.dim; i++)
    {
        FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i];

+        /* The semantic pass on the contracts of the overridden functions must
+         * be completed before code generation occurs (bug 3602 and 5230).
+         */
+        if (fdv->fdensure && fdv->fdensure->semanticRun != PASSsemantic3done)
+        {
+            assert(fdv->scope);
+            fdv->semantic3(fdv->scope);
+        }

        sf = fdv->mergeFensure(sf);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5230


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE(tocsym.c) overriding a  |Regression(2.041, 1.057)
                   |method that has an out      |ICE(tocsym.c) overriding a
                   |contract                    |method that has an out
                   |                            |contract


--- Comment #3 from Don <clugdbug yahoo.com.au> 2010-11-22 07:00:15 PST ---
Actually this needs the patch to bug 5145 applied as well.

I'm not sure which D1 regression this dates from. 1.057 was the first one with
an ICE.
But 1.050 - 1056 gave this error:
override_out_a.d(1760): Error: function __ensure (int) does not match parameter
types ()
override_out_a.d(1760): Error: expected 1 arguments, not 0

and earlier versions of D1 accepted it, but it didn't work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5230


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2010-12-05
21:18:47 PST ---
http://www.dsource.org/projects/dmd/changeset/783

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2010