Jump to page: 1 2
Thread overview
[Issue 3273] New: struct invariant + dtor fails to compile (no line number)
Aug 30, 2009
2korden@gmail.com
Jun 11, 2010
Don
Jun 15, 2010
Don
Jun 17, 2010
Don
[Issue 3273] Regression(2.031): struct invariant + dtor fails to compile (no line number)
Jul 20, 2010
Don
Sep 14, 2010
Don
Sep 20, 2010
Don
Jan 02, 2011
Don
Jun 18, 2011
Kenji Hara
Jun 18, 2011
Kenji Hara
Jul 14, 2011
Kenji Hara
Aug 05, 2011
Walter Bright
August 30, 2009
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: -------
June 11, 2010
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: -------
June 15, 2010
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: -------
June 17, 2010
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: -------
July 20, 2010
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: -------
September 14, 2010
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: -------
September 20, 2010
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: -------
January 02, 2011
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: -------
June 18, 2011
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


--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2011-06-18 06:46:17 PDT ---
*** 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: -------
June 18, 2011
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


--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2011-06-18 07:28:11 PDT ---
*** 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: -------
« First   ‹ Prev
1 2