D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3293 - ICE(expression.c) recursive alias template parameters
Summary: ICE(expression.c) recursive alias template parameters
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2009-09-03 13:23 UTC by Koroskin Denis
Modified: 2015-06-09 01:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Koroskin Denis 2009-09-03 13:23:55 UTC
template ReferenceType(T)
{
    alias T* ReferenceType;
}

struct SomeRange(T, alias Storage = 0)
{
    bool foo()
    {
        return guard == guard;	// bug 1: replace == with is and DMD crashes with no output
    }

    enum guard = cast(ReferenceType!(T))SomeContainer!(T, Storage).guard;
}

struct SomeContainer(T, alias Storage = 0)
{
    auto opSlice()	// bug 2: replace auto with SomeRange!(T, Storage) and get an ICE
    {
        return SomeRange!(T, Storage)();
    }
	
    enum ReferenceType!(T) guard = cast(ReferenceType!(T))cast(void*)0xFEFEFEFE;	// bug 3: remove guard type and DMD crashes with no output
}

class A
{
    SomeRange!(int, 0) test()	// bug 4: 0 is not omissible
    {
        return SomeContainer!(int)()[];
    }
}
Comment 1 Don 2009-09-07 03:18:35 UTC
(1) I can't see 'mixin' anywhere in any of these bugs!
(2) Cannot reproduce bug 3. 
(3) Please don't report multiple bugs in a single bug report. There are definitely at least 3 different bugs in here.
Bug 1 is Segfault(statement.c)
bug 2 is ICE(expression.c)
bug 4 is a rejects-valid.

It's possible they all have the same root cause, but I doubt it.
Comment 2 Don 2009-09-07 08:29:30 UTC
Bug 1 is now its own issue, bug 3304.
Bug 3 is now its own issue, bug 3305.
They are completely unrelated to one another.
Comment 3 Don 2009-09-08 08:51:49 UTC
Here's a reduced test case for the second bug, which is ICE(expression.c).
Something to do with recursive alias parameters causing data corruption.
Only happens if there is an infinite template expansion, so I think this one is ice-on-invalid-code. Somehow defining the return type as 'auto' circumvents the infinite expansion -- but I'm not sure that it should.

---
alias const(void*) VoidPtr;

struct SomeRange(alias Storage){
    const guard = cast(const void *)Bug3293!(Storage).guard;
}

struct Bug3293(alias Storage){
    SomeRange!(Storage) foo;
    const VoidPtr guard = cast(void *)345;
}

SomeRange!(0)  a = Bug3293!(0)().foo;
Comment 4 Don 2009-09-08 13:30:18 UTC
And the fourth bug has been moved to bug 3307. I'm therefore changing the title to reflect the remaining bug, as described in comment 3.
Comment 5 Koroskin Denis 2009-09-11 02:03:32 UTC
Thanks and sorry for confusion!
Comment 6 Don 2010-11-15 00:17:40 UTC
Fixed DMD2.047.