indexing a tuple containing a struct strange result

Ali Çehreli acehreli at yahoo.com
Sun Jun 23 22:31:29 PDT 2013


On 06/23/2013 10:07 PM, Ali Çehreli wrote:

 > I think it is a compiler bug.

Make that a Phobos bug. :)

The following is a reduced program that exhibits the problem. The 
presence or absence of the unused member function makes a difference:

import std.typecons;

struct S
{
     int x;

     // Bizarre: Comment-out this function to pass the assert in main.
     Tuple!(S) unused()
     {
         return tuple(S(7));
     }
}

void main()
{
     auto s = S(8);

     assert(tuple(s).expand[0] == S(8));
}

Ali



More information about the Digitalmars-d-learn mailing list