D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6030 - Segmentation fault with method overloading and alias this
Summary: Segmentation fault with method overloading and alias this
Status: RESOLVED DUPLICATE of issue 6029
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2011-05-18 11:38 UTC by Robert Clipsham
Modified: 2011-11-03 08:36 UTC (History)
2 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:38:10 UTC
struct A
{
    static A a;
    alias a this;
}

struct B
{
    int opSlice(size_t, size_t);
    int opSlice(size_t, A);
}

void main()
{
    B b;
    b[0..A];
}

Causes a segmentation fault using the latest git. Possibly related to issue #6029.
Comment 1 Trass3r 2011-08-14 14:57:37 UTC
$ gdb --batch -ex 'run test4.d' -ex 'bt 25' dmd
Program received signal SIGSEGV, Segmentation fault.
0x0000000000517f40 in aliasthisConvTo (ad=Cannot access memory at address 0x7fffff7fefe8) at mtype.c:7193
7193	{
#0  0x0000000000517f40 in aliasthisConvTo (ad=Cannot access memory at address 0x7fffff7fefe8) at mtype.c:7193
#1  0x0000000000518380 in TypeStruct::implicitConvTo (this=0x86f2c0, to=0x8631d0) at mtype.c:7269
#2  0x0000000000518120 in aliasthisConvTo (ad=0x86f110, from=0x86f2c0, to=0x8631d0) at mtype.c:7213
#3  0x0000000000518380 in TypeStruct::implicitConvTo (this=0x86f2c0, to=0x8631d0) at mtype.c:7269
#4  0x0000000000518120 in aliasthisConvTo (ad=0x86f110, from=0x86f2c0, to=0x8631d0) at mtype.c:7213
#5  0x0000000000518380 in TypeStruct::implicitConvTo (this=0x86f2c0, to=0x8631d0) at mtype.c:7269
#6  0x0000000000518120 in aliasthisConvTo (ad=0x86f110, from=0x86f2c0, to=0x8631d0) at mtype.c:7213
...
Comment 2 Kenji Hara 2011-08-14 16:12:32 UTC
Mutually recursion version.

struct A
{
    static B b;
    alias b this;
}

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

struct C
{
    int opSlice(size_t, size_t){ return 0; }
    int opSlice(size_t, A){ return 0; }
}

void main()
{
    C c;
    c[0..A];
}
Comment 3 Trass3r 2011-11-03 08:36:39 UTC
This has nothing to do with method overloading.
It's a stack overflow caused by aliasthisConvTo.

*** This issue has been marked as a duplicate of issue 6029 ***