D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7583 - [CTFE] ICE with tuple and alias this
Summary: [CTFE] ICE with tuple and alias this
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: CTFE, ice
Depends on:
Blocks:
 
Reported: 2012-02-25 06:44 UTC by aneas
Modified: 2012-03-01 11:51 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 aneas 2012-02-25 06:44:17 UTC
The following code results in a CTFE error. The bad line is "array_of_tuples ~= Tuple!(int, int)(0, 0);"


import std.typecons;

void function_evaluated_at_compiletime() {
    Tuple!(int, int)[] array_of_tuples;
    array_of_tuples ~= Tuple!(int, int)(0, 0);
}

void main() {
    mixin(function_evaluated_at_compiletime());
}


$ dmd main.d
dmd: interpret.c:94: Expression* CtfeStack::getValue(VarDeclaration*): Assertion `v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < stackPointer()' failed.
Aborted

DMD64 D Compiler v2.058
Comment 1 Don 2012-02-27 12:22:32 UTC
Reduced test case. Seems to be very complicated.

----------------
template Tup7583(E...) { alias E Tup7583; }

struct S7583
{
    Tup7583!(float, char) field;
    alias field this;    
    this(int x) {    }
}


int bug7583() {
    S7583[] arr;
    arr ~= S7583(0);
    return 1;
}

static assert (bug7583());
Comment 2 Don 2012-02-28 01:41:17 UTC
This is a front-end bug. Happens with == as well as ~=.
The front-end creates a temporary tuple variable __tup5.
Somehow the declaration of __tup5 gets removed. The ICE is because it's used before being declared.
Comment 3 github-bugzilla 2012-02-29 23:58:47 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/bcfd90aae05bd6259212ec870b2c037569029d77
Merge pull request #773 from 9rnsr/fix7583

fix Issue 7583 - [CTFE] ICE with tuple and alias this