www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3273] New: struct invariant + dtor fails to compile (no line number)

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

           Summary: struct invariant + dtor fails to compile (no line
                    number)
           Product: D
           Version: 2.031
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P3
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: 2korden gmail.com


The following is a minimal test-case to reproduce the bug:

module A;

struct A {
    ~this() {
    }

    invariant() {
    }
}

 dmd A

Note that this is a regression since DMD2.030 successfully compiled the code above. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 30 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3273


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-06-11 04:43:07 PDT ---
The error message is generated while running the semantic pass on the
synthesised opAssign().

Here's an extraordinary variation:

struct A {
    ~this() {    }
    invariant() {    }
    A opAssign(A a) { return this; }
}
--
Error: cannot goto forward into different try block level


This has to be the most bizarre and unhelpful error message I've ever seen in
D.

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



--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-06-15 13:23:27 PDT ---
There's a few different issues involved in this.
(1) The result variable isn't mutable.
Generated opAssign will return a const(A), because the result variable is
in func.c 1114:
                if (!isVirtual())
                    v->storage_class |= STCconst;

because opAssign is not virtual. This line of code was added in svn 259 as part
of the fix for bug 3390 (out(result) contract should not be able to rebind
result). I think this line of code is wrong.

(2) The result variable isn't an lvalue.
This is the bug which was introduced in 2.031.

(3) invariant + dtor + a non-void function with this struct as parameter, has
never worked.
For example this code fails on 2.022 with "cannot goto forward into different
try block level". It's never worked.

struct A {
    invariant() {   }
    ~this() { }
    int blah(A a) { return 0; }
    void opAssign(A a) {}
}

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



--- Comment #3 from Don <clugdbug yahoo.com.au> 2010-06-17 13:44:50 PDT ---
(In reply to comment #2)
 (3) invariant + dtor + a non-void function with this struct as parameter, has
 never worked.
 For example this code fails on 2.022 with "cannot goto forward into different
 try block level". It's never worked.

I've moved that case into a new bug, bug 4339, since it's not a regression, unlike the test case in this bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 17 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3273



--- Comment #4 from Don <clugdbug yahoo.com.au> 2010-07-20 00:21:01 PDT ---
(In reply to comment #3)
 (In reply to comment #2)
 (3) invariant + dtor + a non-void function with this struct as parameter, has
 never worked.
 For example this code fails on 2.022 with "cannot goto forward into different
 try block level". It's never worked.

I've moved that case into a new bug, bug 4339, since it's not a regression, unlike the test case in this bug.

Now that bug 4339 is fixed, there's a reasonable workaround for this bug: create an opAssign. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 20 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3273


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #5 from Don <clugdbug yahoo.com.au> 2010-09-14 11:42:15 PDT ---
PATCH: A normal opAssign, such as in the case below, does not have 'isref' set. 

struct A {
    A opAssign(A a){ return this; }
}

Compiler-generated opAssign shouldn't either.


clone.c line 143,  StructDeclaration::buildOpAssign()
------------
    Parameter *param = new Parameter(STCnodtor, type, Id::p, NULL);
    Parameters *fparams = new Parameters;
    fparams->push(param);
    Type *ftype = new TypeFunction(fparams, handle, FALSE, LINKd);
-#if STRUCTTHISREF
-    ((TypeFunction *)ftype)->isref = 1;
-#endif

    fop = new FuncDeclaration(0, 0, Id::assign, STCundefined, ftype);

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



--- Comment #6 from Don <clugdbug yahoo.com.au> 2010-09-20 08:34:31 PDT ---
Have just discovered bug 4714, which still fails with this patch. I think this
patch is wrong.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alex.khmara gmail.com


--- Comment #7 from Don <clugdbug yahoo.com.au> 2011-01-01 22:26:12 PST ---
*** Issue 5397 has been marked as a duplicate of this issue. ***

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