D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6029 - Regression(2.053): DMD stack overflow with invalid alias this
Summary: Regression(2.053): DMD stack overflow with invalid alias this
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: ice
: 6030 (view as issue list)
Depends on:
Blocks:
 
Reported: 2011-05-18 11:15 UTC by Robert Clipsham
Modified: 2012-02-05 00:02 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Robert Clipsham 2011-05-18 11:15:08 UTC
struct A
{
    static A a;
    alias a this;
}

void foo(A a)
{
}

void main()
{
    foo(A);
}

Results in a stack overflow using latest git. No overflow with 2.052.
Comment 1 yebblies 2011-07-03 09:28:16 UTC
For me this prints:
TypeExp::toElem()
testx.d(13): Error: type A is not an expression

on win32.
So it seems to be fixed, unless it is platform specific.  Please reopen if so.
dmd 2.054
Comment 2 Robert Clipsham 2011-07-10 04:44:57 UTC
Works for me now.
Comment 3 Trass3r 2011-11-03 08:34:59 UTC
It isn't fixed.

struct A
{
    static A a;
    alias a this;
}

void foo(A a)
{
}

void main()
{
//  foo(A);    // Error: type A is not an expression
    int s = A; // Error: type A has no value + stack overflow
}
Comment 4 Trass3r 2011-11-03 08:36:39 UTC
*** Issue 6030 has been marked as a duplicate of this issue. ***
Comment 5 Trass3r 2011-11-03 08:43:09 UTC
caused by mtype.c:
// 'from' is A and 'to' is int
static MATCH aliasthisConvTo(AggregateDeclaration *ad, Type *from, Type *to)
{
    assert(ad->aliasthis);
    Declaration *d = ad->aliasthis->isDeclaration();
    if (d)
    {   assert(d->type);
        Type *t = d->type; // <-- gets struct type A again
        if (d->isVarDeclaration() && d->needThis())
        {
            t = t->addMod(from->mod);
        }
...
        MATCH m = t->implicitConvTo(to);

Guess it should be caught earlier though.
Comment 6 yebblies 2012-02-01 03:41:31 UTC
>  int s = A; // Error: type A has no value + stack overflow

I still can't reproduce this.  What version/os?
Comment 7 github-bugzilla 2012-02-05 00:02:00 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8ba1ff182f138ce21bb83fc9868b35f6b0e2b361
add test case for Issue 6029 - Regression(2.053): DMD stack overflow with invalid alias this
Comment 8 Walter Bright 2012-02-05 00:02:37 UTC
I couldn't reproduce it, but I added it to the test suite.