[Issue 7810] [CTFE] Typesafe variadic function with array of structs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 26 11:47:05 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7810


Dmitry Olshansky <dmitry.olsh at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ctRegex!`a|b` asserts at    |[CTFE] Typesafe variadic
                   |regex.d:1150                |function with array of
                   |                            |structs


--- Comment #6 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-09-26 11:47:45 PDT ---
I've finally pinned down this bugger. 
The problem is in typesafe variadic function if the parameter type is a struct.

See simple test below:
//encoded IR instruction
struct Bytecode
{
    uint raw;
}

int fn1(T)(T[] items...)
{
    assert(items[0] == 20);
    return 42;
}

int fn2(T)(T[] items...)
{
    assert(items[0] == Bytecode(20));
    return 42;
}

//this passes...
static assert(fn1(20, 30) == 42); 

//this dies inside of fn2
static assert(fn2(Bytecode(20), Bytecode(30)) == 42); 

void main()
{//both of these pass at R-T
    assert(fn1(20, 30) == 42); 
    assert(fn2(Bytecode(20), Bytecode(30)) == 42);
}

Output:

sr_micro.d(15): Error: assert(items[0u] == Bytecode(20u)) failed
sr_micro.d(23):        called from here: fn2((Bytecode[2u] __arrayArg6 = void;
 , __arrayArg6[0u] = Bytecode(20u) , __arrayArg6[1u] = Bytecode(30u) ,
cast(Bytecode[])__arrayArg6))
sr_micro.d(23):        while evaluating: static assert(fn2((Bytecode[2u]
__arrayArg6 = void;
 , __arrayArg6[0u] = Bytecode(20u) , __arrayArg6[1u] = Bytecode(30u) ,
cast(Bytecode[])__arrayArg6)) == 42)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list