www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2514] New: indexing error in struct.tupleof[i]

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2514

           Summary: indexing error in struct.tupleof[i]
           Product: D
           Version: 1.036
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: shro8822 vandals.uidaho.edu


template Foo(T, uint n = 0)
{
   static if(T.tupleof.length <= n) const char[] Foo = "";
   else const char[] Foo = typeof(T.tupleof[n]).stringof ~ " " ~ Foo!(T,n+1);
}

import std.stdio;
void main()
{
  writef("%d, %s\n", __VERSION__, Foo!(S)); /// generates "int, int, int"
}

struct S { int i; uint j; float k; }

for this, the following is a work around:

-   else const char[] Foo = typeof(T.tupleof[n]).stringof ~ " " ~ Foo!(T,n+1);
+   else const char[] Foo = typeof(T.tupleof)[n].stringof ~ " " ~ Foo!(T,n+1);


-- 
Dec 13 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2514


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-08-25 12:40:16 PDT ---
Fixed in 2.023 and 1.039

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