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
Error: __result = this is not an lvalue 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



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




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





 (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






 (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



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




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 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
----------------------------------------------------------------------------
                 CC|                            |alex.khmara gmail.com



*** 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
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3273


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



*** Issue 4714 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: -------
Jun 18 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3273


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lat7h virginia.edu



*** Issue 3973 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: -------
Jun 18 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3273


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k.hara.pg gmail.com



---
https://github.com/D-Programming-Language/dmd/pull/139

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


Walter Bright <bugzilla digitalmars.com> changed:

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



10:33:44 PDT ---
https://github.com/D-Programming-Language/dmd/commit/427cf066458dca989bab3a2f4d45330a92df95f6

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